WorksheetsJAVA FUNDAMENTALS
Total questions: 12
Worksheet time: 4mins
Which of the following can be operands of arithmetic operators?
Numeric
Boolean
Both Numeric & Characters
Characters
What will be the output of the following Java program?
class Output {
public static void main(String args[]) {
int a = 1;
int b = 2;
int c;
int d;
c = ++b;
d = a++;
c++;
b++;
++a;
System.out.println(a + " " + b + " " + c); }
}
3 2 4
3 2 3
2 3 4
2 4 4
3 4 4
Which of these can be returned by the operator &?
Integer
Boolean
Integer or Boolean
Character
What will be the output of the following Java program?
class comma_operator {
public static void main(String args[]) {
int sum = 0;
for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1)
sum += i;
System.out.println(sum); }
}
5
4
6
14
Which of these can not be used for a variable name in Java?
identifier
identifier & keyword
keyword
none of the mentioned
What will be the output of the following Java code?
class operators {
public static void main(String args[]) {
int x = 8;
System.out.println(++x * 3 + " " + x); }
}
24 8
24 9
27 9
27 8
Which of the following is not an operator in Java?
instanceof
sizeof
>>>=
new
What will be the output of the following Java program?
class jump_statments {
public static void main(String args[]) {
int x = 2;
int y = 0;
for ( ; y < 10; ++y) {
if (y % x == 0)
continue;
else if (y == 8)
break;
else
System.out.print(y + " "); }
}
}
1 3 5 7
2 4 6 8
1 3 5 7 9
1 2 3 4 5 6 7 8 9
Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?
while
do-while
for
none of the mentioned
What will be the output of the following Java code?
class Relational_operator {
public static void main(String args[]) {
int var1 = 5;
int var2 = 6;
System.out.print(var1 > var2); }
}
5
6
true
false
Which of these is not a bitwise operator?
&
&=
|=
<=
What is the output of relational operators?
Integer
Boolean
Characters
Double
