0% found this document useful (0 votes)
0 views

Final Qus Model Java Programming Paper - 2025 By _ SILAS

The document outlines an expected Java programming exam paper for BSc CS 4th Semester, including questions on Java fundamentals, features, OOP principles, exception handling, and more. It consists of three sections: Section A with multiple-choice questions, Section B with short answer questions, and Section C with detailed explanations and programming tasks. Key topics covered include method overloading, inheritance, packages, and the applet lifecycle.

Uploaded by

silasmacx
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Final Qus Model Java Programming Paper - 2025 By _ SILAS

The document outlines an expected Java programming exam paper for BSc CS 4th Semester, including questions on Java fundamentals, features, OOP principles, exception handling, and more. It consists of three sections: Section A with multiple-choice questions, Section B with short answer questions, and Section C with detailed explanations and programming tasks. Key topics covered include method overloading, inheritance, packages, and the applet lifecycle.

Uploaded by

silasmacx
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Java Programming – BSc CS 4th Sem (2025

Expected Paper)

Section A – One Mark (10 x 1 = 10)

1. What is the extension of Java bytecode file?


.class

2. Which keyword is used to inherit a class in Java?


extends

3. Is Java a compiled or interpreted language?


Both

4. Which method is the entry point of a Java program?


main

5. Name the superclass of all Java classes.


Object

6. Which keyword is used to define a constant?


final

7. Which exception occurs when a number is divided by zero?


ArithmeticException

8. What is JVM?
Java Virtual Machine

9. What does JDK stand for?


Java Development Kit

10. Which loop is entry-controlled?


for

Section B – Five Marks (5 x 5 = 25)

11. Explain features of Java.


Java is a high-level, object-oriented programming language known for the following
features:
- Platform Independence: Java code is compiled into bytecode which runs on any
system with the JVM, regardless of the OS.
- Object-Oriented: Everything in Java is based on classes and objects.
- Secure: Java eliminates issues like pointer usage and provides a secure class loader
and bytecode verifier.
- Robust: It has strong memory management, automatic garbage collection, and
exception handling.
- Multithreaded: Java supports multithreading.
- High Performance: With JIT compiler, Java achieves high speed.

12. Write a Java program to find factorial using recursion.

class Factorial {
int fact(int n) {
if(n == 0) return 1;
else return n * fact(n - 1);
}
public static void main(String[] args) {
Factorial f = new Factorial();
int result = f.fact(5);
System.out.println("Factorial: " + result);
}
}

This program uses recursion to calculate the factorial.

13. Explain method overloading with example.


Method Overloading allows multiple methods with same name but different
parameters.

class MathOps {
int add(int a, int b) {
return a + b;
}
double add(double a, double b) {
return a + b;
}
}

It improves code readability and flexibility.

14. Explain 'this' keyword in Java.


'this' is a reference to the current object.
- Used to differentiate between local and instance variables
- Can call constructors
- Returns current object

15. Difference between Interface and Abstract Class.

Interface Abstract Class

All methods are abstract Can have concrete and abstract methods

No constructors Can have constructors

Variables are final Variables can be any type

Supports multiple inheritance Does not support multiple inheritance

Section C – Eight Marks (5 x 8 = 40)

16. Describe OOPs principles in detail with examples.


Java OOPs Principles:
1. Encapsulation: Wrapping data and methods.
2. Inheritance: One class derives properties from another.
3. Polymorphism: Ability to take many forms (method overloading/overriding).
4. Abstraction: Hiding internal implementation.
Example:

class Student {
private int id;
public void setId(int i) { id = i; }
public int getId() { return id; }
}

17. Explain exception handling in Java with try-catch-finally.

try {
int result = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Error: " + e.getMessage());
} finally {
System.out.println("Execution Done");
}

try handles code, catch manages exceptions, finally always executes.

18. Write a Java program to implement multilevel inheritance.

class A {
void msgA() { System.out.println("Class A"); }
}
class B extends A {
void msgB() { System.out.println("Class B"); }
}
class C extends B {
void msgC() { System.out.println("Class C"); }
}
public class Test {
public static void main(String[] args) {
C obj = new C();
obj.msgA();
obj.msgB();
obj.msgC();
}
}

19. Discuss packages and access specifiers in Java.


Packages group classes together. Example:

package mypackage;
public class MyClass { ... }

Access Specifiers:
- public: accessible everywhere
- private: within same class
- protected: same package + subclass
- default: package-level access

20. Explain Applet lifecycle with diagram.


Lifecycle Methods:
- init(), start(), paint(), stop(), destroy()
Diagram:
init() → start() → paint()
↑ ↓
stop() destroy()

public class MyApplet extends Applet {


public void init() {
System.out.println("Applet Initialized");
}
}

Download as PDF

You might also like