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.
This question is based on the following C++ code segment and class FUN :
class FUN
{
int CODE ;
public :
FUN ( ); //Function1
FUN (int C); //Function2
FUN (FUN & F); //Function3
void DISP ( ); //Function4
~FUN ( ); //Function5
};
void main ( )
{
FUN F1 ;
______ // BLANK
______
}
Which of the following C++ command/ statement can be written in the line marked as BLANK to invoke the function whose prototype is marked as Function 3 ?
AFUN F2;
BFUN F2 (501);
CFUN F2 (F1);
DFUN F2 = F1;
Show answerHide answer
Correct answer: (C) FUN F2 (F1);
Explanation
Function 3, FUN(FUN &F), is the copy constructor, which runs when a new object is made from an existing one, as in FUN F2(F1). (FUN F2 = F1; also calls it, but C is the direct form.)
This question is based on the following C++ code segment and class FUN:
class FUN
{
int CODE ;
public :
FUN ( ); //Function1
FUN (int C); //Function2
FUN (FUN & F); //Function3
void DISP ( ); //Function4
~FUN ( ); //Function5
};
void main ( )
{
FUN F1 ;
______ // BLANK
______
}
Which of the following is called a destructor of the class FUN ?
AFUNCTION 1
BFUNCTION 2
CFUNCTION 3
DFUNCTION 5
Show answerHide answer
Correct answer: (D) FUNCTION 5
Explanation
A destructor has the class name with a tilde and no arguments, so ~FUN() (Function 5) is the destructor.
The teacher provides study material a day before teaching the same thing students read it according to their ability and use the time to complete the assignments in the class with the help of teacher what type of approach is highlighted in the statement?
ABlended learning
BDistance learning
CVirtual learning
DTraditional learning
Show answerHide answer
Correct answer: (A) Blended learning
Explanation
Studying the material before class and using class time for assignments with the teacher is the flipped-classroom model, a form of blended learning that mixes self-study with face-to-face teaching.
Assessments like unit test and class tests are covered under following ______
ASummative assessment
BPortfolio assessment
CFormative assessment
DCCE
Show answerHide answer
Correct answer: (C) Formative assessment
Explanation
Unit tests and class tests happen during teaching to check progress and give feedback, so they are formative assessment. Summative assessment comes at the end of a term.
This question is based on the following C++ code segment and class FUN : class FUN
class FUN
{
int CODE ;
public :
FUN ( ); //Function1
FUN (int C); //Function2
FUN (FUN & F); //Function3
void DISP ( ); //Function4
~FUN ( ); //Function5
};
void main ( )
{
FUN F1 ;
______ // BLANK
______
______}
Which of the following is an example of default constructor?
AFunction 1
BFunction 2
CFunction 3
DFunction 5
Show answerHide answer
Correct answer: (A) Function 1
Explanation
A default constructor takes no arguments, so FUN() (Function 1) is the default constructor. FUN(int) is parameterized, FUN(FUN&) is the copy constructor, and ~FUN() is the destructor.
Which of the following is depicted from the flowchart shown below?
Flowchart (top to bottom, one straight path): P=1000 → R=10 → T=2 → SI=P*R*T/100 → PRINT SI
ASequencing
BBranching
CLooping
DOverloading
Show answerHide answer
Correct answer: (A) Sequencing
Explanation
The flowchart runs straight from top to bottom with no decisions or loops, which is sequencing (sequential control flow).
Virtual functions give run-time (dynamic) polymorphism: the function called is chosen at run time from the object's actual type. Overloading is resolved at compile time.
An interface that provides I/O transfer of data directly to and from the memory unit and the peripheral, is termed as ______.
ADDA
BSerial Interface
CBR
DDMA
Show answerHide answer
Correct answer: (D) DMA
Explanation
DMA (Direct Memory Access) lets a peripheral transfer data directly to or from main memory without the CPU handling each word. The CPU only starts the transfer and is told when it ends.
Correct answer: (C) Two accompanying interfaces and one XML file
Explanation
An EJB (EJB 2.x) bean class comes with two interfaces, the home interface and the remote (or component) interface, plus one XML deployment descriptor (ejb-jar.xml).
In object-oriented programming, by wrapping up characteristics and behavior into one unit, we achieve
AData abstraction
BData encapsulation
CData hiding
DAll of these
Show answerHide answer
Correct answer: (B) Data encapsulation
Explanation
Encapsulation wraps data (characteristics) and the functions that act on it (behaviour) into one unit, the class. Data hiding and abstraction are results of this.
This question is based upon the following class and code segment :
class STOCK
{ float price ;
public :
STOCK( ) ; // Function 1
STOCK(float P) ; // Function 2
STOCK(STOCK &S) ; // Function 3
void INIT( ) ; // Function 4
void DISP( ) ; // Function 5
~ STOCK( ) ; // Function 6
};
void main( )
{
STOCK S2(10) ; // Statement 1
______
______ // Other Statements
______
}
Which of the following declaration/statement will invoke the default constructor of the class - STOCK?
ASTOCK S1(S2);
BSTOCK S2;
CSTOCK S1(20);
DS2.INIT();
Show answerHide answer
Correct answer: (B) STOCK S2;
Explanation
Corrected: the book's key says (a), but STOCK S1(S2) calls the copy constructor. A declaration without arguments, like STOCK S2, invokes the default constructor.
Which constructor will be called by the following lines of code.?
(i) Student S1;
(ii) Student S2 = S1
AFirst copy constructor, then default constructor.
BFirst default constructor, then copy constructor.
CDefault constructors for both lines of code.
DCopy constructors for both lines of code.
Show answerHide answer
Correct answer: (B) First default constructor, then copy constructor.
Explanation
Student S1; creates an object with no arguments, so the default constructor is called. Student S2 = S1; initialises a new object from an existing one, so the copy constructor is called.
Assume the C++ definition : class circle : public point
Which of the following is false?
A'Point' is the base class and 'circle' is the derived class.
BThe colon (:) in the header of class definition indicates inheritance.
CThe keyword 'public' indicates type of inheritance.
DAll the public and protected members of class 'circle' are inherited as public and protected members, respectively, into class 'point'.
Show answerHide answer
Correct answer: (D) All the public and protected members of class 'circle' are inherited as public and protected members, respectively, into class 'point'.
Explanation
Inheritance flows from the base class to the derived class. The public and protected members of point are inherited into circle, not the other way round, so statement D is false.
What is the function of data input command in I/O command?
AActivate the peripheral and to inform it what to do
BTo check status conditions in the interface and the peripheral
CIt cause the interface to respond by transferring data from bus into one of its registers
DIt cause the interface to respond by transferring data from one of its register to bus
Show answerHide answer
Correct answer: (D) It cause the interface to respond by transferring data from one of its register to bus
Explanation
On a data input command the interface takes the data received from the peripheral into its buffer register and places it from that register onto the data bus, so the CPU can read it.
Object-oriented programming is organised around objects. Procedural programming is built on procedures, functional programming on functions, and logic programming on facts and rules.
In Object Oriented Programming, when a new class created from an existing class using principle of inheritance, then the new class is known as ________.
ANew class
BChild class
CMember class
DDerived class
Show answerHide answer
Correct answer: (D) Derived class
Explanation
A class created from an existing class by inheritance is called a derived class (subclass). The existing class is the base class.
Match the following.
i. Overriding — A. Allows a function of operator to be given more then one definition
ii. Over loading — B. A function that is called to deallocate memory
iii. Destructor — C. The ability to change the definition of an inherited method
Ai-A, ii-C, iii-B
Bi-C, ii-B, iii-A
Ci-C, ii-A, iii-B
Di-B, ii-C, iii-A
Show answerHide answer
Correct answer: (C) i-C, ii-A, iii-B
Explanation
Overriding redefines an inherited method in a derived class, overloading gives one function or operator several definitions, and a destructor releases memory/resources when an object is destroyed.
________ act as a interface between a domain expert and an expert system.
ALanguage Editor
BK editor
CIntelligent editor
DKnowledge Editor
Show answerHide answer
Correct answer: (C) Intelligent editor
Explanation
In expert systems, the intelligent (knowledge-acquisition) editor is the interface the domain expert or knowledge engineer uses to enter and refine the knowledge base.
The syllabus of Environment studies for class III to V is woven around the 6 interconnected themes. Which of the following is/are among those themes?
I. Shelter
II. Water
III. Food
AI and III
BII and III
COnly III
DI, II, and III
Show answerHide answer
Correct answer: (D) I, II, and III
Explanation
The NCERT EVS syllabus for classes III-V uses six themes: Family and Friends, Food, Shelter, Water, Travel, and Things We Make and Do. So all three are themes.
Q34DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
There are three main concepts that any language needs to support to be an object-oriented language. Which of the following is one of them?
I. Encapsulation
II. Inheritance
III. Polymorphism
AI and II
BII and III
CI and III
DI, II and III
Show answerHide answer
Correct answer: (D) I, II and III
Explanation
The three pillars of object-oriented programming are encapsulation, inheritance and polymorphism, so a language must support all three.
Q35DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
Which of the following is a component of Decision Support System (DSS)?
I. User interface
II. Knowledge engine
AOnly I
BOnly II
CBoth I and II
DNeither I nor II
Show answerHide answer
Correct answer: (C) Both I and II
Explanation
A DSS has a user interface for interacting with the user, plus a database and a model base or knowledge engine that does the analysis. Both are components.
Q36DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
Which matrix represents rotation of an object by 30° about the origin?
AR30 = [ 1/2 √3/2; √3/2 −1/2 ]
BR30 = [ √3/2 −1/2; 1/2 √3/2 ]
CR30 = [ −1/2 √3/2; √3/2 1/2 ]
DR30 = [ √3/2 −1/2; √3/2 1/2 ]
Show answerHide answer
Correct answer: (B) R30 = [ √3/2 −1/2; 1/2 √3/2 ]
Explanation
The rotation matrix is [cosθ −sinθ; sinθ cosθ]. With cos30° = √3/2 and sin30° = 1/2, this gives [√3/2 −1/2; 1/2 √3/2].
Q37DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
________ is used to transfer the data directly to main memory without using CPU.
ADevice drive
BInput/output interface
CDMA controller
DMemory address Register
Show answerHide answer
Correct answer: (C) DMA controller
Explanation
A DMA controller moves data directly between I/O devices and main memory without passing each word through the CPU.
Q38DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
Which of the following statement(s) is/are NOT correct?
I. In case of multi-grade and multi-level situations, teaching learning materials provide vital help to the teachers for effective management of their class.
II. Teaching learning materials are needed for effective self-learning.
AOnly I
BOnly II
CBoth I and II
DNeither I nor II
Show answerHide answer
Correct answer: (D) Neither I nor II
Explanation
Both statements are correct: TLMs help teachers manage multi-grade, multi-level classes, and they support self-learning. So neither statement is incorrect.
Q39DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
________ converts a source code to object code.
ACompiler
BLinker
CEditor
DLoader
Show answerHide answer
Correct answer: (A) Compiler
Explanation
A compiler translates the whole source program into object (machine) code. A linker combines object files, and a loader places the program in memory.
Q40DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
What is the name of the virtual machine component of microsoft .NET Framework which manages the execution of .NET program?
ACode level security
BCross language class inheritance
CCommon language runtime
DCommon type system
Show answerHide answer
Correct answer: (C) Common language runtime
Explanation
The Common Language Runtime (CLR) is the .NET virtual machine: it loads and runs code, and handles JIT compilation, memory management and security.
Q41DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
'It is not always possible to bring real objects to the classroom'. Which of the following is/are the reason(s) behind the given statement?
I. Size of the object
II. Safety
III. Cost
AI, II and III
BII and III
COnly III
DI and II
Show answerHide answer
Correct answer: (A) I, II and III
Explanation
Real objects may be too big or too small, unsafe to bring (dangerous animals, chemicals) or too costly, so size, safety and cost are all reasons.
Q42DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
'If you are planning to teach the different states of India in class VI, then you need to know whether the students are well conversant in using the atlas'. This given statement is referred to which of the following phase(s) of Assessment For Learning?
I. Formative Assessment
II. Diagnostic Assessment
AOnly I
BOnly II
CBoth I and II
DNeither I nor II
Show answerHide answer
Correct answer: (B) Only II
Explanation
Checking whether students already have a prerequisite skill (using an atlas) before teaching a topic is diagnostic assessment of their prior knowledge.
When solving a Sudoku puzzle using computational thinking, which step is the most critical
for ensuring efficiency?
AProblem decomposition
BAbstraction
CBrute force approach
DPattern recognition
Show answerHide answer
Correct answer: (D) Pattern recognition
Explanation
Sudoku is solved efficiently by recognising patterns, such as which numbers are missing in rows, columns and boxes. This cuts down the possibilities far more than brute force.
What is the output of the following JavaScript code?
const obj = { name: "Alice" };
Object.defineProperty(obj, "age",
{
value: 25,
writable: false
});
obj.age = 30;
console.log(obj.age);
Aundefined
BError: Cannot modify property
C25
D30
Show answerHide answer
Correct answer: (C) 25
Explanation
writable: false makes the age property read-only. In non-strict mode, obj.age = 30 is silently ignored, so 25 is printed. Strict mode would throw a TypeError.
Which of the following is NOT true about a Histogram?
ARectangles have bases on vertical axis.
BIt consists of a set of rectangles.
CAreas of the rectangles are proportional to class frequencies
DThese rectangles represent the range of the data
Show answerHide answer
Correct answer: (A) Rectangles have bases on vertical axis.
Explanation
Statement A is false: the bases of a histogram's rectangles lie on the horizontal (x) axis, which shows the class intervals. Frequencies are on the vertical axis.
Which of the following statements about the DOM (Document Object Model) in JavaScript is
true regarding its interaction with HTML and JavaScript?
AThe DOM only allows reading the HTML document but does not permit any changes or
updates.
BThe DOM allows JavaScript to directly modify the structure of the HTML document by
manipulating its elements, attributes and content.
CThe DOM is a static representation of the page and does not update dynamically when
changes occur in the document.
DThe DOM can only interact with text-based HTML documents and cannot modify styles
or events.
Show answerHide answer
Correct answer: (B) The DOM allows JavaScript to directly modify the structure of the HTML document by
manipulating its elements, attributes and content.
Explanation
The DOM is a live tree of the page. JavaScript can use it to add, remove or change elements, attributes, content, styles and events, and the page updates immediately.
Which method is used to loop through all the enumerable properties of an object in
JavaScript?
AObject.values()
BforEach()
Cfor...in
DObject.keys()
Show answerHide answer
Correct answer: (C) for...in
Explanation
The for...in loop iterates over all enumerable property names (keys) of an object. Object.keys() and Object.values() only return arrays, and forEach is an array method.
What does the below code snippet represent?
myObject.doActivity();
ACalling a method named doActivity on the object myObject
BSending a message to the doActivity class
CCreating an object myObject
DSending a message to the child class of myObject
Show answerHide answer
Correct answer: (A) Calling a method named doActivity on the object myObject
Explanation
The dot operator calls the method doActivity() on the object myObject (in OOP terms, sends the message doActivity to that object).
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.