Java Programming
Comprehensive Notes on Java
B y Am a n ku m awa t
, BCA 301: Java Programming
Question Paper pattern for Main University Examination Max Marks: 100
Part-1 (very short answer) consists 10 questions of two marks each with two questions from each unit. Maximum
limit for each question is up to 40 words.
Part-II (short answer) consists 5 questions of four marks each with one question from each unit. Maximum limit
for each question is up to 80 words.
Part-III (Long answer) consists 5 questions of twelve marks each with one question from each unit with internal
choice.
UNIT-I
Java Programming: Basic concept of object oriented programming (objects and classes, data abstraction &
Encapsulation, Inheritance, polymorphism, dynamic binding, Message passing), Java features, JVM,Byte code
interpretation, simple java program, Command line argument, Data types, type casting, operators (Arithmetic,
increment, decrement, relational, Logical, bit wise, Conditional) and expressions.
UNIT- II
Decision Making and Branching: Decision making and branching (if....else, else if, switch). Looping, classes,
objects and methods, constructor, wrapper classes, nesting of methods, overriding methods, final class, visibility
control, arrays, strings.
UNIT-III
Inheritance & Multithreaded programming: Inheritance, types of Inheritance, Abstract class, interfaces,
packages, multithreaded programming, extending thread, life cycle of thread, using thread methods, thread
priority, synchronization.
UNIT-IV
Exception handling: Exception-handling fundamentals, Exception type, try, catch, throw, finally, creating
exception sub classes.
AWT controls (Button, labels, Combo box, list and other Listeners), Layout and component managers, Event
handling, string handling (Only main functions), Graphics programming (Line, rectangles, circle and ellipses).
UNIT-V
Overview of Networking in Java: URL class and its usage through connection, Sockets based connectivity,
TCP/IP Sockets and Server sockets, Datagram Sockets.
Introduction to Java beans: BDK, JAR Files, Servlets Life Cycle of Servlet, JDBC connectivity.
, UNIT-I Java Programming
Java Programming: Basic concept of object oriented programming (objects and classes, data abstraction
& Encapsulation, Inheritance, polymorphism, dynamic binding, Message passing), Java features, JVM,Byte code
interpretation, simple java program, Command line argument, Data types, type casting, operators (Arithmetic,
increment, decrement, relational, Logical, bit wise, Conditional) and expressions.
1. Basic Concepts of Object-Oriented Programming (OOP)
Java is an object-oriented programming language, which means it is based on the concepts of objects and classes.
Let's break down the key concepts of OOP:
Objects and Classes:
o Class: A class is a blueprint or template that defines the properties (attributes) and behaviors
(methods) of an object. It defines how objects of that class will behave and what data they will
store.
class Car {
String color;
String model;
void start() {
System.out.println("Car is starting...");
}
}
o Object: An object is an instance of a class. It is created based on the class definition and has
actual values assigned to its attributes.
Car myCar = new Car();
myCar.color = "Red";
myCar.model = "Sedan";
myCar.start(); // Calls the start method of the Car class
Data Abstraction and Encapsulation:
o Data Abstraction: It is the concept of hiding the complex implementation details from the user
and exposing only essential features of an object. It helps in focusing on the relevant details.
o Encapsulation: It is the bundling of data (variables) and methods (functions) into a single unit, or
class. It restricts direct access to some of an object's components and can prevent the accidental
modification of data. This is achieved through access modifiers (private, public, protected).
o class BankAccount {
private double balance; // private variable, cannot be accessed directly
public void deposit(double amount) { // public method
, if (amount > 0) {
balance += amount;
}
}
o public double getBalance() { // public method to access the balance
return balance;
}
}
Inheritance:
o Inheritance is a mechanism where one class can inherit properties and methods from another
class. This allows for reusability and establishing a relationship between the parent class
(superclass) and child class (subclass).
class Animal {
void eat() {
System.out.println("Eating...");
}
}
o class Dog extends Animal {
void bark() {
System.out.println("Barking...");
}
}
In this case, Dog inherits the eat() method from Animal.
Polymorphism:
o Polymorphism allows a single entity (method or object) to take multiple forms. It can be achieved
in two ways:
Method Overloading (Compile-time Polymorphism): Multiple methods with the same name
but different parameter lists.
class Calculator {
int add(int a, int b) {
return a + b;
}
Comprehensive Notes on Java
B y Am a n ku m awa t
, BCA 301: Java Programming
Question Paper pattern for Main University Examination Max Marks: 100
Part-1 (very short answer) consists 10 questions of two marks each with two questions from each unit. Maximum
limit for each question is up to 40 words.
Part-II (short answer) consists 5 questions of four marks each with one question from each unit. Maximum limit
for each question is up to 80 words.
Part-III (Long answer) consists 5 questions of twelve marks each with one question from each unit with internal
choice.
UNIT-I
Java Programming: Basic concept of object oriented programming (objects and classes, data abstraction &
Encapsulation, Inheritance, polymorphism, dynamic binding, Message passing), Java features, JVM,Byte code
interpretation, simple java program, Command line argument, Data types, type casting, operators (Arithmetic,
increment, decrement, relational, Logical, bit wise, Conditional) and expressions.
UNIT- II
Decision Making and Branching: Decision making and branching (if....else, else if, switch). Looping, classes,
objects and methods, constructor, wrapper classes, nesting of methods, overriding methods, final class, visibility
control, arrays, strings.
UNIT-III
Inheritance & Multithreaded programming: Inheritance, types of Inheritance, Abstract class, interfaces,
packages, multithreaded programming, extending thread, life cycle of thread, using thread methods, thread
priority, synchronization.
UNIT-IV
Exception handling: Exception-handling fundamentals, Exception type, try, catch, throw, finally, creating
exception sub classes.
AWT controls (Button, labels, Combo box, list and other Listeners), Layout and component managers, Event
handling, string handling (Only main functions), Graphics programming (Line, rectangles, circle and ellipses).
UNIT-V
Overview of Networking in Java: URL class and its usage through connection, Sockets based connectivity,
TCP/IP Sockets and Server sockets, Datagram Sockets.
Introduction to Java beans: BDK, JAR Files, Servlets Life Cycle of Servlet, JDBC connectivity.
, UNIT-I Java Programming
Java Programming: Basic concept of object oriented programming (objects and classes, data abstraction
& Encapsulation, Inheritance, polymorphism, dynamic binding, Message passing), Java features, JVM,Byte code
interpretation, simple java program, Command line argument, Data types, type casting, operators (Arithmetic,
increment, decrement, relational, Logical, bit wise, Conditional) and expressions.
1. Basic Concepts of Object-Oriented Programming (OOP)
Java is an object-oriented programming language, which means it is based on the concepts of objects and classes.
Let's break down the key concepts of OOP:
Objects and Classes:
o Class: A class is a blueprint or template that defines the properties (attributes) and behaviors
(methods) of an object. It defines how objects of that class will behave and what data they will
store.
class Car {
String color;
String model;
void start() {
System.out.println("Car is starting...");
}
}
o Object: An object is an instance of a class. It is created based on the class definition and has
actual values assigned to its attributes.
Car myCar = new Car();
myCar.color = "Red";
myCar.model = "Sedan";
myCar.start(); // Calls the start method of the Car class
Data Abstraction and Encapsulation:
o Data Abstraction: It is the concept of hiding the complex implementation details from the user
and exposing only essential features of an object. It helps in focusing on the relevant details.
o Encapsulation: It is the bundling of data (variables) and methods (functions) into a single unit, or
class. It restricts direct access to some of an object's components and can prevent the accidental
modification of data. This is achieved through access modifiers (private, public, protected).
o class BankAccount {
private double balance; // private variable, cannot be accessed directly
public void deposit(double amount) { // public method
, if (amount > 0) {
balance += amount;
}
}
o public double getBalance() { // public method to access the balance
return balance;
}
}
Inheritance:
o Inheritance is a mechanism where one class can inherit properties and methods from another
class. This allows for reusability and establishing a relationship between the parent class
(superclass) and child class (subclass).
class Animal {
void eat() {
System.out.println("Eating...");
}
}
o class Dog extends Animal {
void bark() {
System.out.println("Barking...");
}
}
In this case, Dog inherits the eat() method from Animal.
Polymorphism:
o Polymorphism allows a single entity (method or object) to take multiple forms. It can be achieved
in two ways:
Method Overloading (Compile-time Polymorphism): Multiple methods with the same name
but different parameter lists.
class Calculator {
int add(int a, int b) {
return a + b;
}