Core Java External
Perfect ✅
Got it — from now on, I’ll act as your Core Java teacher and give exam-ready,
simple, and structured answers based on your BBA–CA (Third Year) level.
Here’s how I’ll respond for each question you ask:
🟢 2 Marks Questions: 4 short, direct bullet points.
🟡 3 Marks Questions: 4–6 clear bullet points.
🔵 5 Marks or More: 6–8+ detailed bullet points or a table if needed.
Language: Easy, neat, and exam-friendly — no long paragraphs.
Style: Each answer will look like neat notes ready for your answer sheet.
You can now start by sending me your first topic or question from Core Java 👇
Here’s your Chapter 1: Java Fundamentals (Exam Notes Format) — all answers are
easy, clean, and at your BBA-CA (Third Year) level 👇
🟢 2 Marks Questions
1️⃣ What is JDK? How to build and run Java program?
JDK (Java Development Kit) is a software package used to develop Java
programs.
It includes JRE (Java Runtime Environment) + compiler (javac) + development
tools.
To build (compile): javac [Link] → creates .class file.
To run (execute): java filename → runs the compiled program.
2️⃣ What is the use of classpath?
Classpath tells Java where to find classes and packages used in a program.
It can include directories, JAR files, or ZIP files.
Without correct classpath, JVM cannot locate the required classes.
It can be set using environment variable CLASSPATH or -classpath option in
command.
3️⃣ What is the difference between Array and ArrayList?
Basis Array ArrayList
Size Fixed size Dynamic (can grow/shrink)
Type Can store primitive Stores only objects
& objects
1/14
Basis Array ArrayList
Performance Faster Slightly slower
Syntax int a[] = new ArrayList<Integer> list =
int[5]; new ArrayList<>();
🟡 3 Marks Questions
4️⃣ What is Java? Why Java is a platform-neutral language?
Java is a high-level, object-oriented programming language developed by Sun
Microsystems (1995).
It is used to create portable, secure, and robust applications.
Platform-neutral means Java code can run on any OS without change.
Java code is compiled into bytecode (.class) which runs on JVM (Java Virtual
Machine).
JVM interprets bytecode for the underlying operating system, ensuring
portability.
🔵 4 Marks Questions
5️⃣ Explain features of Java.
Simple: Easy to learn, similar to C/C++ but without pointers.
Object-Oriented: Everything in Java is based on objects and classes.
Platform-Independent: Java bytecode runs on any OS via JVM.
Secure: No direct memory access; supports authentication and encryption.
Robust: Strong memory management and exception handling.
Multithreaded: Supports multiple threads for parallel execution.
Portable: Same code runs everywhere (Write Once, Run Anywhere).
High Performance: Uses Just-In-Time (JIT) compiler for faster execution.
6️⃣ What is datatype? Explain types of datatypes used in Java.
Datatype:
It defines the type of data a variable can hold.
Helps the compiler allocate proper memory and perform valid operations.
Types of Datatypes in Java:
Type Description Examples
Primitive Datatypes Basic built-in types int, float, char, boolean
Non-Primitive User-defined or String, Array, Class,
Datatypes derived types Interface
Primitive Types (8 Total):
2/14
byte – 1 byte
short – 2 bytes
int – 4 bytes
long – 8 bytes
float – 4 bytes
double – 8 bytes
char – 2 bytes
boolean – 1 bit (true/false)
Would you like me to continue with Unit 2 (Classes, Objects, and Methods) next in
the same format?
Here’s your Chapter 2: Classes, Objects, and Methods (Exam Notes Format) —
written in simple, clear points suitable for BBA–CA (Third Year) 👇
🟢 2 Marks Questions
1️⃣ Define class and object with one example.
Class: A blueprint or template that defines variables and methods for an object.
Object: A real-world instance of a class that has properties and behavior.
Example:
java
class Car {
void run() { [Link]("Car is running"); }
}
class Demo {
public static void main(String[] args) {
Car c = new Car(); // c is an object
[Link]();
}
}
Here, Car = class, and c = object of that class.
2️⃣ Explain static keyword.
Static keyword is used for members shared by all objects of a class.
Can be used with variables, methods, or blocks.
Static members belong to the class, not to any specific object.
Accessed directly using class name (e.g., [Link]() ).
cannot override
🔵 4 Marks Questions
3/14
3️⃣ What is difference between constructor and method? Explain types of
constructors.
Difference between Constructor and Method:
Basis Constructor Method
Purpose Used to initialize objects Used to perform
actions
Name Same as class name Any valid name
Return Type No return type Must have return type
Call Type Called automatically when Called manually using
object is created object
Overloading Can be overloaded Can also be
overloaded
Types of Constructors:
1. Default Constructor:
No arguments, provided by Java compiler if not defined.
Example:
java
class A { A() { [Link]("Default"); } }
2. Parameterized Constructor:
Takes parameters to initialize object with specific values.
Example:
java
class A {
int x;
A(int val) { x = val; }
}
3. Copy Constructor (Java-style):
Copies data of one object into another.
Example:
java
A(A obj) { this.x = obj.x; }
4️⃣ What is a method in Java? Explain method overloading with example.
Method:
A block of code that performs a specific task and may return a value.
Improves code reusability and readability.
4/14
Syntax:
java
returnType methodName(parameters) {
// body
}
Method Overloading:
Defining multiple methods with the same name but different parameters.
Helps perform similar operations with different types or numbers of inputs.
Compiler differentiates using number or type of arguments (known as compile-
time polymorphism).
Example:
java
class MathOp {
int add(int a, int b) { return a + b; }
double add(double a, double b) { return a + b; }
}
Here, add() is overloaded based on parameter types.
Would you like me to continue next with Chapter 3: Inheritance, Packages, and
Collections in the same exam-note format?
Here’s your Chapter 3: Inheritance, Packages, and Collection (Exam Notes Format)
— simplified and structured perfectly for BBA–CA (Third Year) exam answers 👇
🟢 2 Marks Questions
1️⃣ What is Access Specifiers? List them.
Access Specifiers (or Modifiers) define the visibility of classes, methods, and
variables.
They control how data or functions can be accessed by other classes.
Types of Access Specifiers in Java:
1. public – accessible from anywhere.
2. protected – accessible within same package and subclasses.
3. default (no keyword) – accessible only within same package.
4. private – accessible only within the same class.
🟡 3 Marks Questions
2️⃣ What is Package? Write down all the steps for package creation.
5/14
Package is a way to group related classes and interfaces together.
Helps in organizing code and avoiding naming conflicts.
Steps to Create a Package:
1. Use the package keyword at the top of the Java file.
java
package mypack;
2. Save the file inside a folder with the same name as package (e.g., /mypack ).
3. Compile the class with javac -d . [Link] → creates package folder
automatically.
4. Access in another program using import [Link]; .
3️⃣ Define Multiple Inheritance.
Multiple Inheritance means a class can inherit features from more than one
parent class.
Java does not support multiple inheritance using classes to avoid ambiguity
(diamond problem).
It is achieved in Java using interfaces.
Example:
java
interface A { void show(); }
interface B { void display(); }
class C implements A, B {
public void show() {}
public void display() {}
}
🔵 4 Marks Questions
4️⃣ Differentiate between Interface and Abstract Class.
Basis Interface Abstract Class
Keyword Declared using Declared using
interface abstract
Methods All methods are Can have abstract +
abstract by default concrete methods
Variables Public, static, final Can have any type of
by default variable
Inheritance Supports multiple Single inheritance only
inheritance
6/14
Basis Interface Abstract Class
Constructor Cannot have Can have constructors
constructors
Usage Used to define Used for partial
contract/behavior implementation
5️⃣ Explain Method Overloading and Method Overriding in detail.
Concept Method Overloading Method Overriding
Definition Same method name, Same method name &
different parameters parameters in parent & child
class
Type Compile-time Runtime polymorphism
polymorphism
Class Involved Same class Two classes (inheritance)
Return Type Can be same or different Must be same
Keyword Used No special keyword @Override annotation used
Example add(int a, int b) and Child class redefining parent’s
add(double a, double b) method
6️⃣ What is Collection? Explain Collection Framework in detail.
Collection:
A group of objects treated as a single unit.
Found in [Link] package.
Used to store, retrieve, and manipulate dynamic data.
Collection Framework:
A set of classes and interfaces for working with groups of data.
Provides ready-made data structures like List, Set, and Map.
Supports algorithms like sorting, searching, and iteration.
Main Interfaces:
List: Ordered collection (e.g., ArrayList, LinkedList).
Set: No duplicate elements (e.g., HashSet, TreeSet).
Map: Key–value pairs (e.g., HashMap, TreeMap).
Advantages: Reusability, performance, easy maintenance, and flexibility.
7️⃣ What is Super Keyword? Explain its use with suitable example.
super keyword refers to immediate parent class object.
7/14
Used to access parent class members (variables, methods, constructors).
Uses of super :
1. To call parent class constructor.
2. To access parent class variables (if same name exists).
3. To call parent class methods (if overridden).
Example:
java
class Parent {
int num = 10;
void show() { [Link]("Parent"); }
}
class Child extends Parent {
int num = 20;
void show() {
[Link](); // calls Parent method
[Link]([Link]); // access Parent variable
}
}
Output:
nginx
Parent
10
Would you like me to continue with Chapter 4: File Handling and Exception
Handling next in the same format?
Here’s your Chapter 4: File and Exception Handling (Exam Notes Format) — short,
clear, and perfect for BBA–CA (Third Year) exam preparation 👇
🟢 2 Marks Questions
1️⃣ What is the use of Reader and Writer class?
Reader and Writer classes are used for character-based input and output in
Java.
They are part of the [Link] package.
Reader reads data (characters) from files or streams.
Writer writes data (characters) to files or streams.
Example: FileReader , FileWriter .
8/14
2️⃣ What is main difference between Exception and Error?
Basis Exception Error
Meaning Issues that can be Serious problems that
handled by cannot be handled
program
Type Occur due to Occur due to system
logical or runtime failure
mistakes
Handling Can be caught Cannot be recovered
using try-catch
Examples NullPointerExcep OutOfMemoryError ,
tion , StackOverflowError
IOException
🟡 3 Marks Questions
3️⃣ Define term finally block.
finally block is a part of exception handling in Java.
It is used to execute code always, whether an exception occurs or not.
Placed after try–catch block.
Commonly used to close files, release resources, or perform cleanup
operations.
Syntax:
java
try {
// code
} catch(Exception e) {
// handle exception
} finally {
[Link]("Always executed");
}
🔵 4 Marks Questions
4️⃣ Explain the concept of Exception and Exception Handling.
Exception:
An unexpected event that occurs during program execution.
It disrupts normal program flow (e.g., divide by zero, file not found).
Exception Handling:
A mechanism to handle runtime errors so program continues smoothly.
Prevents abnormal program termination.
9/14
Done using five keywords:
1. try – contains risky code.
2. catch – handles exception.
3. finally – executes always.
4. throw – used to throw exception manually.
5. throws – declares exceptions in method signature.
Example:
java
try {
int a = 10 / 0;
} catch(ArithmeticException e) {
[Link]("Error: " + e);
}
5️⃣ What are the different types of Streams? Explain in detail.
Stream:
A sequence of data (flow of data) between a program and a file/device.
Used for Input/Output (I/O) operations.
Types of Streams:
Type Direction Description Example Classes
Input Stream Read Reads data from FileInputStream ,
source BufferedInputStream
Output Stream Write Writes data to FileOutputStream ,
destination PrintStream
Character Stream Read/Write text Handles characters FileReader ,
data (Unicode) FileWriter
Byte Stream Read/Write binary Handles raw bytes InputStream ,
data OutputStream
Note:
Byte streams are used for images, audio, etc.
Character streams are used for text files.
6️⃣ Describe File Handling in brief.
File Handling allows Java programs to read from and write to files.
Done using classes from [Link] package.
Used to store data permanently in secondary storage.
Common Classes:
File – represents file/directory.
10/14
FileReader / FileWriter – for character data.
FileInputStream / FileOutputStream – for byte data.
BufferedReader / BufferedWriter – for efficient reading/writing.
Steps in File Handling:
1. Create or open a file.
2. Read/write data.
3. Close the file to free resources.
Example:
java
FileWriter fw = new FileWriter("[Link]");
[Link]("Hello Java");
[Link]();
Would you like me to prepare Chapter 5: GUI Programming (Applet, AWT, Swing)
next in the same exam-note format?
Here’s your Chapter 5: Applet, AWT, Event, and Swing Programming (Exam Notes
Format) — clear, concise, and perfect for BBA–CA (Third Year) exam preparation 👇
🟡 3 Marks Questions
1️⃣ What is difference between paint() and repaint()?
Basis paint() repaint()
Definition Used to draw graphics or Used to request the system to
display content on applet call paint() again
or frame
Called By Called automatically by the Called manually by
system when applet/frame programmer when update is
is displayed needed
Purpose Draws content for the first Refreshes or updates the
time existing drawing
Example public void repaint() → internally calls
paint(Graphics g) update() → paint()
🔵 4 Marks Questions
2️⃣ What is Layout Manager? Explain any one in detail.
Layout Manager:
11/14
A layout manager controls how components (buttons, text fields, etc.) are
arranged in a container (like Frame or Panel).
Found in [Link] package.
Helps design GUI automatically without manually setting coordinates.
Common Layout Managers:
1. FlowLayout
2. BorderLayout
3. GridLayout
4. CardLayout
Example – FlowLayout:
Arranges components in a row, from left to right.
When space is filled, moves to the next line.
Constructor: new FlowLayout(int alignment, int hgap, int vgap)
Example Code:
java
Frame f = new Frame();
[Link](new FlowLayout());
[Link](new Button("OK"));
[Link](new Button("Cancel"));
[Link](200, 200);
[Link](true);
3️⃣ Difference between Swing and AWT
Basis AWT Swing
Package [Link] [Link]
Components Heavyweight Lightweight (written in
(depend on OS) Java)
Look and Feel Platform- Platform-independent
dependent
Speed Slower Faster
Additional Limited (Button, Many (JButton, JTable,
Components TextField) JTree)
MVC Architecture Not supported Supports MVC
Example Button , Label JButton , JLabel
4️⃣ Explain in brief Delegation Event Model for handling events.
Delegation Event Model:
12/14
Java uses this model to handle events like button clicks, keypress, etc.
Events are generated by source objects and handled by listener objects.
Three main components:
1. Event Source → Object that generates event (e.g., Button).
2. Event Object → Contains details of the event (e.g., ActionEvent ).
3. Event Listener → Interface that receives and handles events (e.g.,
ActionListener ).
Steps in Event Handling:
1. Implement listener interface.
2. Register listener with the source using addListener() method.
3. When event occurs, JVM calls the listener’s method automatically.
Example:
java
[Link](new ActionListener() {
public void actionPerformed(ActionEvent e) {
[Link]("Button Clicked!");
}
});
5️⃣ What is Applet? Explain its types.
Applet:
An applet is a small Java program that runs inside a web browser or applet
viewer.
Used to create interactive web applications.
Must extend the Applet or JApplet class.
Lifecycle methods: init() , start() , stop() , destroy() , paint() .
Types of Applets:
1. Local Applet:
Stored on the local system.
Loaded using file path.
2. Remote Applet:
Stored on a remote server and downloaded via a URL.
Loaded using <applet> tag in HTML or via appletviewer .
Example:
java
import [Link].*;
import [Link].*;
public class HelloApplet extends Applet {
public void paint(Graphics g) {
[Link]("Hello Applet", 50, 50);
13/14
}
}
Would you like me to now create a full “Java Fundamentals to Swing” one-page
revision sheet (chapter-wise keywords, short notes & differences) for final quick
revision before exam?
14/14