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

Which of the following is not a valid way to create a new JavaScript object?

  1. const object = {};

  2. const object = new Object();

  3. const object = { property: value };

  4. const object = [];

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

The const object = []; syntax is not a valid way to create a new JavaScript object. The correct syntax is const object = {};, const object = new Object();, or const object = { property: value };.