menu

Java Classes and Objects


1. Which of the following is not a valid identifier for a class in Java?

MyClass

myclass

my_class

myClass123


2. Which keyword is used to prevent a method from being overridden in a subclass in Java?

final

static

abstract

synchronized


3. Which of the following is true about the super keyword in Java?

It refers to the superclass of the current class.

It refers to the subclass of the current class.

It refers to the current object.

It refers to the current class.


4. Which of the following is true about method return type in Java?

It specifies the name of the method.

It specifies the access specifier of the method.

It specifies the type of value returned by the method.

It specifies the type of parameters accepted by the method.


5. Which of the following is not a type of access modifier in Java?

public

private

protected

package


6. Which keyword is used to refer to the current object in Java?

this

super

final

abstract


7. Which of the following is true about encapsulation in Java?

It allows the state of an object to be accessed directly.

It allows the state of an object to be accessed only through methods.

It allows the state of an object to be accessed only through variables.

It allows the state of an object to be accessed through both variables and methods.


8. Which of the following is not a modifier in Java?

final

static

non-static

public


9. Which of the following is true about interfaces in Java?

They can have instance variables.

They can be instantiated.

They can have both abstract and non-abstract methods.

They can have constructors.


10. Which keyword is used to implement inheritance in Java?

extends

implements

super

this