ourse Title: Programming with Java
Total Marks: 75
Time: 3 Hours
Instructions:
* Answer all questions.
* Part A: 10 MCQs (2 from each unit, 1 mark each).
* Part B: 5 Three-mark questions with internal choice (1 from each unit).
* Part C: 5 Five-mark questions with internal choice (1 from each unit).
Part A: Multiple Choice Questions (10 x 1 = 10 Marks)
Unit I
1. Which paradigm does Java primarily follow?
* (a) Procedural
* (b) Object-Oriented
* (c) Functional
* (d) Logical
2. The primary function of the Java Virtual Machine (JVM) is to:
* (a) Compile source code.
* (b) Interpret bytecode.
* (c) Manage databases.
* (d) Create user interfaces.
Unit II
3. Which keyword declares a variable as unchangeable?
* (a) static
* (b) const
* (c) final
* (d) var
4. The '||' operator in Java performs:
* (a) Bitwise OR
* (b) Logical OR
* (c) Bitwise AND
* (d) Logical AND
Unit III
5. What is the purpose of a constructor?
* (a) To destroy objects.
* (b) To initialize objects.
* (c) To define methods.
* (d) To declare variables.
6. Which keyword is used to implement an interface?
* (a) extends
* (b) inherit
* (c) implements
* (d) derive
Unit IV
7. Which method starts a thread's execution?
* (a) run()
* (b) execute()
* (c) start()
* (d) begin()
8. The 'finally' block is used for:
* (a) Handling all exceptions.
* (b) Executing code regardless of exceptions.
* (c) Defining new exceptions.
* (d) Declaring variables.
Unit V
9. The Graphics class is used for:
* (a) File operations.
* (b) Network programming.
* (c) Drawing shapes.
* (d) Database management.
10. Which class is used to manipulate files in Java?
* (a) Stream
* (b) Graphics
* (c) File
* (d) Vector
Part B: Three-Mark Questions (5 x 3 = 15 Marks)
Unit I
11. (a) Explain the basic principles of Object-Oriented Programming.
OR
(b) Describe the Java Evolution and its key features.
Unit II
12. (a) Explain type casting in Java with examples.
OR
(b) Differentiate between 'if' and 'switch' statements.
Unit III
13. (a) Explain method overloading with a code example.
OR
(b) Explain the purpose of java packages.
Unit IV
14. (a) Explain thread synchronization.
OR
(b) Describe the 'try-catch' block and its usage.
Unit V
15. (a) Explain the use of the Graphics class to draw basic shapes.
OR
(b) Describe the difference between byte streams and character streams.
Part C: Five-Mark Questions (5 x 5 = 25 Marks)
Unit I
16. (a) Write a simple Java program and explain its structure.
OR
(b) Explain the Java Environment and how to configure it.
Unit II
17. (a) Explain the different data types and operators in Java.
OR
(b) Write a Java program to demonstrate the use of loops.
Unit III
18. (a) Explain inheritance and method overriding with a code example.
OR
(b) Explain interfaces and their implementation in Java.
Unit IV
19. (a) Explain multithreading by implementing the Runnable interface.
OR
(b) Explain exception handling with user-defined exceptions.
Unit V
20. (a) Write a Java program to draw a polygon and an arc.
OR
(b) Explain how to read and write primitive data types to a file in Java.