MCQ
Paper - II (v) — Object Oriented Programming using C++ and JAVA MCQ - Practice Questions with Answers
Solve 45 Paper - II (v) — Object Oriented Programming using C++ and JAVA questions for RAS/RPSC preparation.
Practice questions
Q1Which statement about Java checked exceptions is correct?
Java distinguishes checked exceptions from unchecked exceptions. A method that may throw a checked exception must either handle it using an appropriate catch clause or declare it using a throws clause so the obligation is visible to callers. This rule is especially relevant in file handling, where input-output operations commonly declare checked exceptions.
Q2In C++ file handling, which class is most directly suited when the same file stream object must support both input and output operations?
The C++ stream library separates common file-stream roles: ifstream for input, ofstream for output, and fstream for file streams that can support both input and output depending on the open mode. A stringstream is also a stream, but it uses an in-memory string buffer rather than a file.
Q3In C++, a base class pointer points to a derived class object. Which declaration is essential if a call to the function through that pointer must use the derived class implementation at run time?
C++ run-time polymorphism through a base pointer or reference depends on virtual functions. If the base class declares a member function virtual and the derived class provides a matching override, the call is dispatched according to the dynamic type of the object. Changing storage duration, data-member access, or overload sets does not create dynamic binding.
Q4A C++ base class contains at least one pure virtual function. Which conclusion follows from this declaration?
A pure virtual function expresses an abstract operation in a C++ class. The class cannot be directly instantiated, and a derived class that is meant to be concrete must provide final implementations for all inherited pure virtual functions. This is a core way to model interface-like behavior in C++ without changing access rules or involving Java interfaces.
Q5A C++ class Account has private data member balance. Which choice is the most appropriate object-oriented way to allow controlled modification of balance from outside the class?
Encapsulation keeps an object's internal representation behind a public interface. For a field such as balance, the class should retain private storage and expose operations such as deposit or withdraw that validate amounts before changing the state. This is different from simply hiding data for its own sake; the point is to protect class invariants while still allowing useful operations.
You've seen 5 of 45 sample questions
Unlimited practice on Paper - II (v) — Object Oriented Programming using C++ and JAVA comes with the RAS Test Series + Practice pack or Gate Pass.
More questions
6Why is it usually important for a C++ base class intended for polymorphic deletion to have a virtual destructor?
7A Java Swing button must execute code when it is clicked. Which approach best follows the usual event-handling model?
8Which statement correctly contrasts Java class inheritance with Java interface implementation?
9In C++, which condition is necessary for a call through a base-class pointer to invoke the derived-class implementation at run time?
10In Java, which statement correctly describes inheritance between classes?
11Which C++ inheritance form is shown by the declaration class Printer : public Device { ... };?
12In Java file handling, why is try-with-resources preferred for objects such as FileInputStream or BufferedReader?
13In Java event handling, what is the main role of a listener object?
14In a C++ program, class Shape has a virtual member function draw(). Class Circle publicly derives from Shape and overrides draw(). If Shape* p points to a Circle object and p->draw() is executed, which statement best describes the call?
15In Java, what does a finally block associated with try-catch primarily provide?
