Aspirant Academy

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?

A Time-lapse
B Critical situation
C Race condition
D Recursion
Explanation

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++) -

A *(ptrdata ++)
B (*ptrdata)++
C *(ptrdata) ++
D Depends on compiler
Explanation

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.

A A is true
B B is true
C Both (A) and (B) are true
D Neither (A) nor (B) is true
Explanation

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.

A i and ii, iv
B Only ii
C Only iii
D ii and iv Only
Explanation

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”);

A Only I
B Only II
C Both I and II
D Neither I nor II
Explanation

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.

Ai and ii
Bii and iii
Cii and iv
Di, ii and iv

7Choose the incorrect statement -

AIf a method is declared as final, that method cannot be overridden in sub class.
Bfinalize() is a method of java, which is called by garbage collector thread before removing an object from the memory.
CIf a class is declared final, it cannot be inherited. If you do so it will give you compile-time error.
DIf we declare any variable as final, the value of the variable can be modified in final method.

More topics in Data Processing & Programming (Basic CI)

Explore other subjects