Q) False statements about an Abstract class in java
  1. Abstract class act as a base class and can be extended
  2. Abstract class cannot be instantiated.
  3. It can contain only abstract methods.
  4. All of them are correct

Answer: 3
An abstract class in java can have both abstract and non-abstract methods.

Q) Correct differences between throw and throws in java is/are
  1. throw keyword is used to throw an exception explicitly whereas throws clause is used to declare an exception.
  2. By using Throw keyword, we cannot throw more than one exception but using throws we can declare multiple exceptions
  3. throw is used inside method body to invoke an exception and throws clause is used in method declaration (signature).
  4. All of them are correct.

Answer: 4

Q) Readonly variables in java
  1. Can be modified at runtime in non static constructor only.
  2. Can be modified from both method and constructor.
  3. Can never be modified as it behave as constant variable
  4. All are correct.

Answer: 1
Readonly variable can be modified in non-static constructor at run time.
const variable can never be modified across the program once initialized.

Read difference between readonly and const with example in C sharp

Q) In Java static variable is used to
  1. Refer common properties to all objects.
  2. get persistent value between different method call
  3. It gets memory only once in a class area at the time of class loading.
  4. All are correct

Answer: 4

Q) False statement about static method in java
  1. Belongs to class not object of the class
  2. Can be called without any object creation of a class
  3. Can access non static and static variables both.
  4. All are correct.

Answer: 3
Static method in java can access only static variables or static method.

Related Posts