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

OOP_Java_Answers_BCA_2024

The document outlines the BCA Semester Exam for Object Oriented Programming Using Java, covering short and medium answer questions. Key topics include Java API, differences between String and StringBuffer, abstract classes, Java features, constructors, method overloading vs overriding, applet life cycle, thread creation, and user-defined exceptions. Each section provides essential definitions and rules related to Java programming concepts.

Uploaded by

Manoj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

OOP_Java_Answers_BCA_2024

The document outlines the BCA Semester Exam for Object Oriented Programming Using Java, covering short and medium answer questions. Key topics include Java API, differences between String and StringBuffer, abstract classes, Java features, constructors, method overloading vs overriding, applet life cycle, thread creation, and user-defined exceptions. Each section provides essential definitions and rules related to Java programming concepts.

Uploaded by

Manoj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

BCA Semester Exam - Object Oriented Programming Using Java (July/August 2024)

PART - A (Short Answer Questions)

PART - A (2 Marks Each)

1) What is Java API?


Java API is a set of classes and interfaces provided by Java to help developers perform common tasks like file I/O,
networking, data structures, and GUI. It acts as a library to simplify programming.

2) Differences between String and StringBuffer:


- String is immutable; StringBuffer is mutable.
- StringBuffer is thread-safe; String is not.
- String creates a new object on modification; StringBuffer modifies the same object.

3) Differences between this and super keywords:


- this refers to the current class object; super refers to the superclass object.
- this() calls a constructor of the same class; super() calls the superclass constructor.
- this is used for member disambiguation; super accesses overridden members.

4) Define abstract class:


An abstract class in Java is declared with the abstract keyword. It can have both abstract methods (without body) and
concrete methods. It cannot be instantiated directly.

5) Four methods of InputStream and OutputStream:


- read()
- read(byte[] b)
- write(int b)
- write(byte[] b, int off, int len)

6) Typecasting in Java:
Typecasting is converting one data type into another.
- Widening: Implicit (e.g., int to double)
- Narrowing: Explicit using casting (e.g., double to int -> int a = (int) 4.5;)

PART - B (Medium Answer Questions)

PART - B (5 Marks Each)

7) Features of Java:
- Simple: Easy syntax, no pointers.
- Object-Oriented: Based on classes and objects.
BCA Semester Exam - Object Oriented Programming Using Java (July/August 2024)

- Platform Independent: Write once, run anywhere via JVM.


- Secure: Runtime checks and no explicit memory access.
- Multithreaded and Robust: Handles errors and concurrent execution.

8) What is constructor? Rules:


- Name must match class.
- No return type.
- Can be overloaded.
- Can use this() or super() to chain constructors.

9) Method Overloading vs Overriding:


Overloading: Same class, different parameters.
Overriding: Subclass, same method signature.

10) Applet Life Cycle:


- init(): Initializes applet
- start(): Called after init or resume
- paint(Graphics g): For GUI drawing
- stop(): Called when applet is inactive
- destroy(): Cleanup resources

11) Creating thread using Thread class:


1. Extend Thread
2. Override run()
3. Create object
4. Call start()

12) User-defined Exception:


class MyException extends Exception {
MyException(String msg) {
super(msg);
}
}
throw new MyException("error");

You might also like