Computer Knowledge

Object-Oriented Programming

2,239 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 technology programming languages
  1. Implement a no-argument constructor

  2. provide an identifier property

  3. declare accessors for persistent fields

  4. all the above

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

Hibernate requires a no-argument constructor to instantiate objects via reflection when retrieving data from the database. While identifier properties and accessors are best practices, they are not mandatory for basic POJO functionality.

Multiple choice technology programming languages
  1. Table per Concrete class

  2. Table per Sub class

  3. Table per class Hierarchy

  4. all of the above

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

Hibernate supports three inheritance mapping strategies: Table per Concrete Class (each class gets its own table), Table per Subclass (shared parent table with separate subclass tables), and Table per Class Hierarchy (single table for entire hierarchy).

Multiple choice technology programming languages
  1. True

  2. False

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

Overriding methods cannot be more restrictive than the methods they override. This maintains the Liskov Substitution Principle - if the parent method is public, the child must also be public (or more accessible, though 'more accessible than public' doesn't exist). Making it protected or private would break the contract.