Your session has expired

Your progress and purchases are safe. Log in again to continue.

Log in again
Aspirant Academy

MCQ

OOP MCQ - Practice Questions with Answers

Read the sample questions below. Explanations are shown where available.

Practice questions

Q1

If 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.

Q3

Which 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.

Q4

Which 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.

Q5

Which 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.

Sample questions on this page: 5

For package details, choose your exam and check the included practice, access period and final payable total. You do not need to buy anything to view sample questions.

More questions

6

Which 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
7

Choose the incorrect statement:

AIf a method is declared final, it cannot be overridden in a subclass.
Bfinalize() is a Java method called by the garbage collector thread before removing an object from memory.
CIf a class is declared final, it cannot be inherited. Attempting to inherit it causes a compile-time error.
DIf a variable is declared final, its value can be modified inside a final method.

More topics in Data Processing & Programming (Basic CI)

Explore other subjects