62 OOP (Computer Science) questions asked in DSSSB TGT / PGT previous year papers, each with the correct answer and explanation. Read them free on UTpaper, or attempt the full papers as timed online tests.
What is the objective of encapsulation in object-oriented programming?
ATo create multiple instances of a class
BTo enable one class to inherit from another class
CTo allow objects to take multiple forms
DTo combine data and methods that operate on that data within a single unit
Show answerHide answer
Correct answer: (D) To combine data and methods that operate on that data within a single unit
Explanation
Encapsulation bundles data and the methods that act on it into one unit (class) and hides internal details. Inheritance and polymorphism are options B and C.
DPackages are used to prevent naming conflicts, and packages are considered data encapsulation.
Show answerHide answer
Correct answer: (A) Packages cannot provide controlled access.
Explanation
Packages do provide controlled access through package-private (default) and protected access. They also prevent naming conflicts and support encapsulation.
Which of the following is NOT a feature of object-oriented programming?
AGlobal variables
BFunction overloading
CEncapsulation
DAbstraction
Show answerHide answer
Correct answer: (A) Global variables
Explanation
Encapsulation, abstraction and polymorphism (such as function overloading) are OOP features. Global variables break encapsulation and are not an OOP feature.
The ______ design is high-abstraction version of a system that is followed by ______ design that breaks the concept into less-abstracted view of sub-systems and later the ______ design showcases the implementation at module-level.
System design gives the most abstract view of the whole system. Architectural design breaks it into sub-systems and components, and detailed design specifies each module for implementation.
Which of the following is a translator that translates source code into object target code?
ALanguage processor
BInterpreter
CCompiler
DAssembler
Show answerHide answer
Correct answer: (C) Compiler
Explanation
A compiler translates the whole high-level source program into object (target) code in one go. An interpreter executes line by line without producing object code, and an assembler translates only assembly language.
B"static public void main(String...abcd){}" is a valid statement.
CAbstract classes cannot be instantiated.
DInterface allows default method definitions.
Show answerHide answer
Correct answer: (A) Final methods can be overridden.
Explanation
A final method cannot be overridden in a subclass, so (A) is false. The varargs main with modifiers in any order is valid, abstract classes cannot be instantiated, and Java 8 interfaces allow default methods.
In building software, should preferably be lower and is preferred to be on the higher side.
Ainheritance from parent class, dependency with peer classes
Baggregation with peer components, composition among classes
Cnone of the given answer
Dcoupling among components, cohesion in bonding components
Show answerHide answer
Correct answer: (D) coupling among components, cohesion in bonding components
Explanation
Good software design aims for low coupling (little dependency between components) and high cohesion (elements inside a component strongly related), which makes systems easier to maintain and reuse.
What feature of OOP allows an instance of a class to take on many forms?
AOperator overriding
BMultiple inheritance
CNested class
DOperator overloading
Show answerHide answer
Correct answer: (D) Operator overloading
Explanation
The ability to take many forms is polymorphism. Operator overloading is a form of compile-time polymorphism, where one operator behaves differently for different types, which is why it is the keyed option.
Which access modifier can be used to access members in deriving class?
AVoid
BProtected
CPrivate
DPublic
Show answerHide answer
Correct answer: (B) Protected
Explanation
Protected members are accessible inside the class and in classes derived from it, but not to unrelated outside code. Private members are not accessible in derived classes.
How to use these DSSSB TGT / PGT Computer Science questions
Every question here was asked in a real DSSSB TGT / PGT paper; the paper and shift are shown on the card, and the number opens the question on its own page. Try each one before tapping Show answer, then attempt the full DSSSB TGT / PGT papers as timed tests to check your speed under exam conditions.