Unit5 - Subjective Questions

CSE310 • Practice Questions with Detailed Answers

1

Differentiate between Byte Streams and Character Streams in Java I/O.

2

Explain the hierarchy of Java I/O Streams.

3

What is Object Serialization and Deserialization? Write a code snippet to demonstrate writing an object to a file.

4

Explain the significance of the transient keyword in Java Serialization.

5

Discuss the Try-with-resources statement. How does it improve I/O exception handling?

6

Define Generics in Java. What are the main advantages of using Generics?

7

Create a custom Generic class named Box that can store an object of any type T. Include methods to set and get the object.

8

Explain Bounded Types in Generics. How do you restrict a Generic type to accept only numbers?

9

What are Wildcards in Java Generics? Explain the difference between Upper Bounded, Lower Bounded, and Unbounded wildcards.

10

Describe the Lifecycle of a Thread in Java. What are the various states a thread can be in?

11

Compare implementing the Runnable interface versus extending the Thread class for creating threads.

12

Explain the concept of Thread Synchronization. Why is it necessary?

13

How is Inter-thread Communication achieved in Java? Explain wait(), notify(), and notifyAll().

14

What are Thread Priorities? How can we set and get the priority of a thread in Java?

15

Write a Java program to create two threads: one printing even numbers and the other printing odd numbers up to 10.

16

What is the Type Inference Diamond <> operator introduced in Java 7? Give an example.

17

Explain the difference between join() and yield() methods in the Thread class.

18

What is a Deadlock? Describe a scenario where a deadlock might occur in Java.

19

Explain the purpose of the File class in java.io. It is a stream?

20

What is Type Erasure? How does it affect Generic code at runtime?