Question 1 of 25
Hints left: 3
Q1
What should be expression1 evaluate to in using ternary operator as in this line? expression1 ? expression2 : expression3
Q2
What will be the output of the following Java program? class Output { public static void main(String args[]) { int a,b,c,d; a=b=c=d=20; a+=b-=c*=d/=20; System.out.println(a+" "+b+" "+c+" "+d); } }
Q3
What is the output of relational operators?
Q4
Which of these statements is correct?
Q5
The while loop repeats a set of code while the condition is not met?
Q6
What will be the output of the following Java program? class selection_statements { public static void main(String args[]) { int var1 = 5; int var2 = 6; if ((var2 = 1) == var1) System.out.print(var2); else System.out.print(++var2); } }
Q7
Which of these have highest precedence?
Q8
What will be the output of the following Java code? class ternary_operator { public static void main(String args[]) { int x = 3; int y = ~ x; int z; z = x > y ? x : y; System.out.print(z); } }
Q9
Which keyword is used to define a method in Java?
Q10
Which of the following is not a valid jump statement?
Q11
What is true about a break?
Q12
Which of the following is not a decision making statement?
Q13
Which of these selection statements test only for equality?
Q14
Decrement operator, - -, decreases the value of variable by what number?
Q15
Which of these is returned by "greater than", "less than" and "equal to" operators?
Q16
Modulus operator, %, can be applied to which of these?
Q17
What will be the output of the following Java code? class bool_operator { public static void main(String args[]) { boolean a = true; boolean b = !true; boolean c = a | b; boolean d = a & b; boolean e = d ? b : c; System.out.println(d + " " + e); } }
Q18
What would be the output of the following code snippet if variable a=10? if(a<=0) { if(a==0) { System.out.println("1 "); } else { System.out.println("2 "); } } System.out.println("3 ");
Q19
What is a constructor in Java?
Q20
What is the valid data type for variable "a" to print "Hello World"? switch(a) { System.out.println("Hello World"); }
Q21
In Java, which method is automatically called when an object is created?
Q22
What is method overloading in Java?
Q23
What will be the output of the following Java program? class bitwise_operator { public static void main(String args[]) { int var1 = 42; int var2 = ~var1; System.out.print(var1 + " " + var2); } }
Q24
Which of the following is not a valid flow control statement?
Q25
From where break statement causes an exit?