Core Java Questions and Answer for Interview

91. Name the eight primitive Java types?
The eight primitive types are byte, char, short, int, long, float, double, and boolean.

92. What restrictions are placed on the values of each case of a switch statement?
During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.

93. What is the difference between a while statement and a do while statement?
A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do while statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do while statement will always execute the body of a loop at least once.

94. What modifiers can be used with a local inner class?
A local inner class may be final or abstract.

95. When does the compiler supply a default constructor for a class?
The compiler supplies a default constructor for a class if no other constructors are provided.

96. If a method is declared as protected, where may the method be accessed?
A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

97. What are the legal operands of the instanceof operator?
The left operand is an object reference or null value and the right operand is a class, interface, or array type.

98. Are true and false keywords?
The values true and false are not keywords.

99. What happens when you add a double value to a String?
The result is a String object.

100. What is the diffrence between inner class and nested class?
When a class is defined within a scope od another class, then it becomes inner class=If the access modifier of the inner class is static, then it becomes nested class.

User Answer

  1. Be the first one to express your answer.

Core Java Questions and Answer for Interview