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 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); } }
Q3
The while loop repeats a set of code while the condition is not met?
Q4
What is true about a break?
Q5
What is a constructor in Java?
Q6
From where break statement causes an exit?
Q7
What is the output of relational operators?
Q8
What is the valid data type for variable "a" to print "Hello World"? switch(a) { System.out.println("Hello World"); }
Q9
Which of the following is not a valid jump statement?
Q10
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); } }
Q11
Which of the following is not a decision making statement?
Q12
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 ");
Q13
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); } }
Q14
Which of these have highest precedence?
Q15
Modulus operator, %, can be applied to which of these?
Q16
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); } }
Q17
In Java, which method is automatically called when an object is created?
Q18
Which of these selection statements test only for equality?
Q19
Which of the following is not a valid flow control statement?
Q20
Which of these is returned by "greater than", "less than" and "equal to" operators?
Q21
Which keyword is used to define a method in Java?
Q22
What is method overloading in Java?
Q23
Which of these statements is correct?
Q24
Decrement operator, - -, decreases the value of variable by what number?
Q25
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); } }