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. inheritance

  2. reprehensibility

  3. extensibility

  4. encapsulation

  5. abstraction

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

The capability of a programming language to upgrade itself to accommodate new data types which are in new format as per need is called extensibility of that language.

Multiple choice
  1. Class variables have static keyword.

  2. Instance variables are declared within any method.

  3. Local variable is initialised outside the method.

  4. Instance variable can be accessed outside any method.

  5. Local variable is declared outside any method.

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

Local variables are defined and initialised inside a method. Instance variables may be declared outside a method and can be accessed only inside that method. Class variables are declared within a class and with static keyword.

Multiple choice
  1. class

  2. object

  3. encapsulation

  4. inheritance

  5. polymorphism

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

Encapsulation binds the functions of a program with data. It is a characteristic feature of object oriented programming language. The encapsulated object behaves as if it is a black box.

Multiple choice
  1. Weather station

  2. Component design

  3. Map database

  4. Weather data

  5. Interface design

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

 This is a package of software-controlled instruments, which collects data that performs some data processing and transmits this data for further processing.

Multiple choice
  1. Public, protected

  2. Only public

  3. Public, protected, private, static, final, or abstract

  4. Only static

  5. Public, private, protected, static but not final

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

All the accessibilties can be given to non-local inner class, which is a member of the outer class. It only gives weaker accessiblilty to non-local inner class, which can be abstract, final, or private(as it is accessible inside outer class).

Multiple choice
  1. Compiler error in line with comment LINE A because fly() does not declare to throw CannotFlyException.

  2. Compiler error in line with comment LINE B because fly() is not defined and hence need to declare it abstract.

  3. It crashes after throwing the exception CannotFlyException.

  4. Walk cannot fly

  5. None of the above

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

To override a method, mentioning exception is not important but if you specify Exception, then the specified exception must be the same or a subclass of the specified exception in the method defined in the super class (or interface).