Computer Knowledge

Object-Oriented Programming

2,686 Questions

Object-oriented programming questions test core computer science concepts like classes, inheritance, polymorphism, and encapsulation. The focus includes Java program structures, method overloading, and memory allocation for objects. This topic is essential for technical sections in various recruitment tests.

Java class definitionsMethod overriding rulesPolymorphism conceptsGeneric type parametersMemory allocation in objects

Object-Oriented Programming Questions

Multiple choice
  1. FirstTh is a simple class.

  2. FirstTh is a class that inherits from Thread class.

  3. FirstTh is a class that implements from Thread class.

  4. FirstTh is a class that implements Runnable interface.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Here FirstTh must be a class which implements Runnable interface. Because the statements FirstTh th=new FirstTh(); Thread sm=new Thread(th).start(); Are used to create a thread by implementing Runnable interface.

Multiple choice
  1. is always public

  2. is always private

  3. can be public or private

  4. cannot be defined

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Member functions can have different access modifiers, such as public, private, or protected, to control their visibility and accessibility.

Multiple choice
  1. To build a user interface

  2. To initialize a newly created object

  3. To free memory

  4. to create a sub class

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Constructors are special methods invoked during the creation of an object to initialize its state.