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 general knowledge
  1. Object-oriented program

  2. Object-oriented programming

  3. Object-orient programming

  4. Option-oriented programming

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

OOP stands for Object-Oriented Programming, a programming paradigm based on objects containing data and code.选项 A is grammatically incomplete,选项 C has incorrect grammar ('Object-orient'), and选项 D ('Option-oriented') is completely wrong.

Multiple choice general knowledge science & technology
  1. this

  2. super

  3. this()

  4. super()

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

In Java, this() is used to call one constructor from another constructor in the same class. It must be the first statement in the constructor body. 'this' alone refers to the current object instance, while 'super' and 'super()' are used for parent class references and constructors respectively.

Multiple choice general knowledge math & puzzles
  1. 8

  2. 6

  3. 5

  4. 4

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

Let C be classes and M be methods per class. Total = CM. Also Total = (C-2)(M+1). CM = CM + C - 2M - 2 => C - 2M = 2. For C=8, M=3 (Total 24). If C=6, M=4 (Total 24). This fits the condition.

Multiple choice general knowledge math & puzzles
  1. Adapter

  2. Bridge

  3. Composite

  4. Strategy

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

The Bridge pattern is specifically designed to decouple an abstraction from its implementation, allowing both to vary independently. This is useful when you want to avoid a permanent binding between an abstraction and its implementation. Adapter converts interfaces, Composite composes objects into tree structures, and Strategy defines interchangeable algorithms.

Multiple choice general knowledge
  1. Memento

  2. Command

  3. Builder

  4. Proxy

Reveal answer Fill a bubble to check yourself
D Correct answer
Multiple choice softskills creativity
  1. boolean

  2. Boollean

  3. Bolean

  4. Boolean

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

Boolean is the correct wrapper class name for the primitive boolean in Java. Option A is the primitive type (not wrapper), while options B and C are misspelled. Java wrapper classes follow specific capitalization rules.

Multiple choice softskills creativity
  1. Import new package

  2. use concrete class

  3. Use of Interfaces

  4. Use Inheritance

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

Java does not support multiple inheritance of classes to avoid complexity and the 'diamond problem'. However, it allows a class to implement multiple interfaces, effectively providing a way to achieve the benefits of multiple inheritance.

Multiple choice softskills creativity
  1. static variable

  2. Abstract method

  3. Initializer Block

  4. Instance variables

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

In Java, static variables are initialized when the class is loaded, and initializer blocks (both static and instance) run before the constructor body. Static blocks run once at load time; instance blocks run every time an object is created, just before the constructor.

Multiple choice softskills creativity
  1. constructor

  2. public instance variable

  3. protected members

  4. Primitive elements

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

Constructors are not inherited in Java - each class must have its own constructors. When a subclass is instantiated, it calls the superclass constructor (implicitly or explicitly via super()), but it does not inherit the constructor itself. Public instance variables, protected members, and primitive elements are all inherited by subclasses.

Multiple choice technology programming languages
  1. True

  2. False

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

When overriding a method, the overriding method cannot throw broader (checked) exceptions than the overridden method. It can throw the same exceptions, a subset, or subclasses of those exceptions, maintaining the contract established by the parent method.