MCQ
OOP MCQ - Practice Questions with Answers
Solve 7 OOP questions for RAS/RPSC preparation.
Practice questions
Q1If three threads are trying to share a single object at the same time which condition will arise in the scenario?
When different threads operate on the same shared data and their steps interleave, the result can depend on timing. This timing-dependent concurrency problem is called a race condition. Therefore the scenario matches option C.
Q2‘ptrdata’ is a pointer to a data type. The expression *ptrdata++ is evaluated as (C++) -
In C++, postfix increment has higher precedence than unary indirection. Therefore `*ptrdata++` is parsed as `*(ptrdata++)`, not as `(*ptrdata)++`. Hence option A is correct.
Q3Which of the following statements is/are true regarding Java? A. Constants that cannot be changed are declared using the `static` keyword. B. A class can inherit only one class but can implement multiple interfaces.
Statement A is false because Java uses `final` for a variable that may be assigned only once; `static` only makes a member belong to the class. Statement B matches Java's inheritance rule: a class extends only one class but may implement multiple interfaces. Hence option B is correct.
Q4Which statement is/are true about Exception handling? i. There can be try block without catch block but vice versa is not possible. ii. There is no limit on the number of catch block corresponding to a try block. iii. The object must be created of a specific class of which the error has occurred otherwise runtime error will occur. iv. To execute a code with each and every run of program, the code is written in finally block.
In exception handling, a try block can be used without a catch block if it is followed by finally, but a catch block cannot stand alone. A single try block can have multiple catch blocks, and finally is used for code intended to run after the try-catch flow in normal execution. Statement iii is false because exceptions are handled through compatible exception types, not by creating an object of the class where the error occurred; therefore i, ii, and iv are true.
Q5Which of the following methods will create string in Java? I : String S = “Hello Java”; II : String S2 = new String (“Hello Java”);
Both statements create a Java String. Statement I uses a string literal, and statement II uses the String constructor with the correct Java capitalization, new String(...). Therefore option C is correct.
You've seen 5 of 7 sample questions
Unlimited practice on OOP comes with the RAS Test Series + Practice pack or Gate Pass.
More questions
6Which of the following statement is/are incorrect with respect to abstract classes? i. Subclasses of an abstract class that do not provide an implementation of an abstract method, are also abstract. ii. Constructor and static methods cannot be declared in abstract class. iii. Sometimes we can create objects directly. iv. An abstract method must always be redefined in a concrete subclass of an abstract class.
7Choose the incorrect statement -
