wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Advanced MCQs on OOPs and FileInputOutput Stream

Total questions: 30

Worksheet time: 30mins

Name
Class
Date
1.

Which of the following statements about inheritance is false?

a)

A subclass can access protected members of its superclass.

b)

A subclass can override private methods of its superclass.

c)

A subclass can inherit final variables from superclass.

d)

A subclass constructor always calls the superclass constructor.

2.

If a superclass constructor takes parameters, what must the subclass constructor do?

a)

It must call super() with arguments explicitly.

b)

It can skip calling super().

c)

It must override all superclass methods.

d)

It must be declared abstract.

3.

What will happen if a subclass defines a field with the same name as in its superclass?

a)

Causes compile-time error

b)

Field hiding occurs

c)

Method overriding occurs

d)

The superclass variable is replaced

4.

What is true about method overloading?

a)

It depends on the return type only.

b)

It depends on the method name and parameter list.

c)

It depends only on the method name.

d)

It depends on the access modifier.

5.

Which of the following cannot be abstract?

a)

Class

b)

Method

c)

Constructor

d)

Interface

6.

When is a constructor called during inheritance?

a)

After the child class constructor

b)

Before the child class constructor

c)

Randomly

d)

Only when explicitly called

7.

What will happen if an abstract class has no abstract methods?

a)

It cannot be instantiated.

b)

It can be instantiated.

c)

It throws a compile-time error.

d)

It must have at least one abstract method.

8.

What happens when a subclass does not override an abstract method from its superclass?

a)

Compilation succeeds

b)

The subclass must be declared abstract

c)

The method becomes private

d)

The subclass can still be instantiated

9.

What happens when two classes have the same method and a third class inherits both (via interfaces)?

a)

Compilation error unless the method is overridden.

b)

Both methods execute.

c)

JVM picks one randomly.

d)

It’s not allowed in Java.

10.

Which concept allows a class to have multiple methods with the same name but different signatures?

a)

Overriding

b)

Overloading

c)

Encapsulation

d)

Abstraction

11.

Which of these exceptions is unchecked?

a)

IOException

b)

SQLException

c)

NullPointerException

d)

FileNotFoundException

12.

Can a finally block modify the value returned by a try block?

a)

Yes, the finally block can change the return value.

b)

No, it always executes after return.

c)

Yes, but only for primitive types.

d)

No, it executes before return.

13.

Which of the following is true about exception handling hierarchy?

a)

Throwable → Exception → RuntimeException

b)

Exception → Throwable → RuntimeException

c)

Throwable → Error → Exception

d)

Exception → Error → Throwable

14.

What happens if an exception is thrown inside a catch block?

a)

It is ignored.

b)

It must be handled by another catch block or the method.

c)

JVM stops immediately.

d)

It goes to the finally block only.

15.

Can a try block exist without a catch block?

a)

No

b)

Yes, if followed by finally

c)

Yes, if inside another try

d)

Yes, always

16.

Which statement is true about checked exceptions?

a)

They occur at runtime.

b)

They must be caught or declared using throws.

c)

They cannot be propagated.

d)

They are subclasses of Error.

17.

What happens when an exception occurs and is not handled?

a)

Program resumes execution normally.

b)

JVM terminates the program.

c)

Exception is ignored.

d)

Compiler adds a default catch block.

18.

Which of the following cannot be caught using a catch block?

a)

IOException

b)

ArithmeticException

c)

StackOverflowError

d)

RuntimeException

19.

What happens if two packages contain classes with the same name?

a)

Compilation error

b)

Use of fully qualified name is required

c)

Both are imported automatically

d)

One overrides the other

20.

Can we import a subpackage automatically by importing the parent package?

a)

Yes

b)

No

21.

Which package is imported automatically in all Java programs?

a)

java.util

b)

java.io

c)

java.lang

d)

java.net

22.

What is the main advantage of using packages?

a)

Slows down compilation

b)

Helps organize classes and avoid naming conflicts

c)

Increases code size

d)

Makes code platform-dependent

23.

What happens when FileReader is used on a binary file?

a)

Works fine

b)

May lead to data corruption or unreadable output

c)

Reads all data correctly

d)

Throws IOException always

24.

Which stream reads raw bytes from a file?

a)

FileReader

b)

FileInputStream

c)

BufferedReader

d)

PrintWriter

25.

What happens if you write to a closed stream?

a)

IOException is thrown

b)

Data is buffered

c)

It automatically reopens

d)

It writes nothing silently

26.

Which of these statements about BufferedReader is true?

a)

It reads character data efficiently using buffering.

b)

It reads binary data.

c)

It cannot be chained with other readers.

d)

It is slower than FileReader.

27.

What is the difference between FileWriter and BufferedWriter?

a)

BufferedWriter writes faster by reducing disk access.

b)

FileWriter is used only for binary data.

c)

BufferedWriter can’t wrap FileWriter.

d)

FileWriter automatically adds buffering.

28.

What will happen if a file doesn’t exist when FileInputStream is created?

a)

A new file is created.

b)

IOException is thrown.

c)

Returns null.

d)

File is ignored.

29.

Which class is used for reading both bytes and characters efficiently?

a)

DataInputStream

b)

RandomAccessFile

c)

FileReader

d)

BufferedReader

30.

What happens when two FileOutputStreams write to the same file simultaneously?

a)

The data is merged automatically.

b)

The file content may get corrupted.

c)

Both streams write alternately.

d)

The JVM prevents concurrent access.