Home Interview Questions and Answers Core Java Interview Questions and Answers For Freshers and Experience Part-21

core-java121. To what value is a variable of the String type automatically initialized?

The default value of an String type is null.

122. What is the difference between a field variable and a local variable?

A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method.

123. How are this() and super() used with constructors?

this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

124. What does it mean that a class or member is final?

A final class cannot be inherited. A final method cannot be overridden in a subclass. A final field cannot be changed after it’s initialized, and it must include an initializer statement where it’s declared.

125. What does it mean that a method or class is abstract?

An abstract class cannot be instantiated. Abstract methods may only be included in abstract classes. However, an abstract class is not required to have any abstract methods, though most of them do. Each subclass of an abstract class must override the abstract methods of its superclasses or it also should be declared abstract.

126. What is a transient variable?

Transient variable is a variable that may not be serialized.

You may also like

Leave a Comment