menu

Java Classes and Objects


1. Which of the following is true about method signature in Java?

It consists of method name and parameter types.

It consists of method name and return type.

It consists of method name, parameter types, and return type.

It consists of method name and access specifier.


2. Which of the following is true about method overriding in Java?

It allows a subclass to provide its own implementation of a method in the superclass.

It allows a superclass to provide its own implementation of a method in the subclass.

It allows a method to have the same name but different signature as another method in the same class.

It allows a method to have a different name but same signature as another method in the same class.


3. Which keyword is used to declare a variable constant in Java?

final

static

abstract

volatile


4. Which of the following is not a method in the Object class in Java?

toString()

hashCode()

equals()

clone()


5. Which of the following is a constructor in Java?

public void MyClass()

public MyClass()

public int MyClass()

public MyClass(int x)


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

They can be instantiated.

They can contain concrete methods.

They can contain instance variables.

They cannot contain constructor.


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

this

object

self

current


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

extends

implements

super

this


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

They are declared inside a method or block.

They have default values.

They are initialized automatically.

They can be accessed from any method in the class.


10. Which method is used to compare two objects for equality in Java?

toString()

hashCode()

equals()

compareTo()