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. These are used to declare the data of a class.

  2. The most commonly used parameters are copy/retain/assign in the Property.

  3. The assign keyword generates a setter, which do not have retained objects.

  4. The assign can be interchanged with another object's property.

  5. The read-only keyword is used to generate the setters.

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

The read-only keyword means a setter will not be generated.

Multiple choice
  1. It is used to implement the code for the accessors.

  2. Synthesised accessors are atomic.

  3. Synthesised accessors can not be nonatomic.

  4. The getters must have a value as per the setters.

  5. There is no cost for the synthesised property if garbage collection is enabled.

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

One can disable the synthesised property with the keyword nonatomic.

Multiple choice
  1. These are used to declare methods for others to implement.

  2. These are used to declare the interfaces to a particular class.

  3. Protocols establish the common attributes among the classes in different hierarchy.

  4. Protocols manage the execution state of the application.

  5. Protocols play an important role in OS X and iOS development.

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

Protocols do not manage the execution state for the application and these are used to declare the application's functionality.

Multiple choice
  1. These are used to maintain a common abstract superclass for all the subclasses.

  2. These provide the specific values based on the inputs for all the subclasses.

  3. The abstract class for the Cluster can not be defined with the composite object.

  4. Bool is a Cluster class of NSNumber.

  5. It uses the functionality like abstract factory.

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

The composite object must declare itself to be a subclass of the cluster's abstract superclass.

Multiple choice
  1. It acts as a medium between the memory system and the garbage collection.

  2. All the released objects are included in the autorelease pool.

  3. All of the objects must be passed in a method pool.

  4. Some objects can be forced to autorelease.

  5. Every program must create its own object.

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

The objects cannot be forced to autorelease.

Multiple choice
  1. A category can be declared for any class in the source code.

  2. It cannot be declared for any class, only for the classes that have original implementation of source code.

  3. All the methods in a category should be applicable to all the instances of the class.

  4. All the methods in a category should be applicable to all subclasses of the original class.

  5. At runtime, there's no difference between a method added by a category with its implementation.

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

A category can be declared for any class even without implemented code.

Multiple choice
  1. An Extension can be declared for any class in the source code.

  2. It cannot be declared for any class in the source code.

  3. Extensions are also known as anonymous categories.

  4. The methods and variables declared inside the extensions are not accessible to the child classes.

  5. @interface keyword is used to declare the extension.

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

An extension cannot be declared for any class, only for the classes that have original implementation of source code.

Multiple choice
  1. class classname {varibale declaration function declaration};

  2. class {variables; function;};

  3. class classname{variables function};

  4. class classname;{ };

  5. class classname {member variables; member function;}

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

This is the correct syntax of declaring a class and members of the class.