Guide Questions and Answers Latest
Version Rated A+
What will be the output of `System.out.println(2 + 3 * 4);`?
A. 20
✔✔B. 14
C. 24
D. Compilation error
Which keyword is used to define a constant variable in Java?
A. static
B. var
✔✔C. final
D. const
What is the result of `System.out.println();`?
A. 4.5
✔✔B. 4
1
,C. 5
D. Compilation error
Which of the following is NOT a valid loop in Java?
A. for
B. while
✔✔C. repeat
D. do-while
What is the default value of an integer instance variable?
✔✔A. 0
B. null
C. undefined
D. garbage value
What will `System.out.println(15 % 4);` print?
A. 4
✔✔B. 3
2
,C. 1
D. 0
Which operator is used for concatenation in Java?
A. -
B. *
C. /
✔✔D. +
What does `System.out.println("Java".length());` print?
A. 5
✔✔B. 4
C. 3
D. Compilation error
What is the superclass of all Java classes?
A. String
B. ObjectClass
3
, ✔✔C. Object
D. ParentClass
Which collection class allows duplicate elements?
✔✔A. ArrayList
B. HashSet
C. TreeSet
D. EnumSet
Which of the following is NOT a primitive data type?
✔✔A. String
B. boolean
C. int
D. char
What will `System.out.println(4 + 5 + "Java");` print?
A. 9
✔✔B. 9Java
4