Week 1
Week 1
• Introduction: OOP paradigm, the creation of java, the java buzzwords; C, C++ and Java
comparison;
• Java Basics: Compilation and execution of a java program, access modifiers, garbage collection;
• Class and Objects: Class definition, creating objects, role of this keyword, garbage collection,
finalize() method, method overloading, objects as parameters, argument passing, returning
objects, access control, final, nested and inner classes;
• I/O Basics: Reading console input, writing console output, Files
• Array and Strings: Arrays in java, 1-D, 2-D and dynamic arrays, string basics, string
comparison and manipulation;
• Inheritance: Inheritance and its types, abstract class, inner and outer class, super, final, static
keywords;
• Package and Interface: In-built packages and user define packages, role of interface,
polymorphism via inheritance;
• Collection Framework & Generics: List, set, map, generic classes;
• Exception Handling: Errors and exceptions, types of exceptions, handling exceptions,
• Multithreading: Thread class, runnable, thread life cycle, synchronization, thread priority;
• Event Handling and GUI Programming: Events, action listener, swing package;
TEXT BOOKS
– Herbert Schildt “Java The Complete Reference”, McGraw
Hill, 11th Edition, December 2020, ISBN-10:9390491622,
ISBN-13: 978-9390491629.
REFERENCE BOOKS
– Balagurusamy E“Programming with Java” , McGraw Hill,
6th Edition, March 2019, ISBN-10: 9353162343, ISBN-13:
978-9353162344.
– Horstmann C. S., “Big Java Early Objects”, Wiley India,
5th Edition, January 2015, ISBN-10:9788126554010,
ISBN-13: 978-8126554010
• What is an Object ?
• Graphical View of an Object
• Object Examples
• What is a Class ?
• Object vs Class ?
• Class Examples
State/Data
Part
Operations/Logic/Algorithmic Part
A Software
Object
• Box Object :
o State/Data Part : length, width, height, Color [Attributes/Instance Fields]
o Behavior Part: computing area, computing volume [Operations, Methods]
• Dog Object :
o State/Data Part : name, breed, color [Attributes / Instance Fields]
o Behavior Part : barking, fetching, wagging [Operations, Methods]
• Account Object :
o State/Data Part : account number, account holder name, balance, type
of account [Attributes/ Instance Fields]
o withdrawing an amount, depositing an amount, checking balance of a
account [ Behavior, Operations, Methods]
}
Access modifier- public, private protector
Default is public
Object
Declaration
It is declaring a variable name with an object type
Ex: Animal buzo; where animal is class and buzo is
reference_variable_name
Working: Animal buzo;
Instantiation: this is when memory is allocated for an object.
New keyword is used to create the object
Ex: Buzo=new
Initialization: the new keyword is followed by a call to a
constructor. This call initials the new object.
Ex: Animal buzo= new Animal(); or
Animal buzo; buzo = new animal();
How to call behaviour of class
Object.method()
Ex: buzo.run();
A small program
class animal1 {
void eat(){
System.out.println("Eating");
}
:Box
}// End of class
:Box
Box b2 = new Box(); b2 length width height
p1
public void setX(double value)
{
x y
x = value;
}
public void setY(double value)
Point p2 = new Point();
:Point
{
y = value;
}
}// End of class
p2 x y
• Abstraction
• Encapsulation
1. Object
2. Class
3. Abstraction
4. Encapsulation
5. Inheritance
6. Polymorphism
OOPs Language
SmallTalk
Java
C++
CSharp
Python
See and find
what this image
says
In this diagram, you can see that
the user only knows there is a
book window for borrowing and
returning books,
He doesn't care or doesn't need to
know about how the book is
found and what happens before
and after he requests or return a
book.
In other words, he is abstracted
from all the details involved in
getting the book to the window.
Abstraction
https://en.wikipedia.org/wiki/Abstraction_(software_engineering)
• Way of managing complexity by suppressing the complex details
• Abstraction refers to the act of representing essential features that are
of interest of the users without including background details or
explanation.
• Users of a complex system are presented with a well defined simple
interface for its use
• Classes use the concept of abstraction for hiding unnecessary
implementation/algorithmic details of its methods.
• As user of any ‘class’ what you should be aware about that class ?
class BOX
{
private double length;
private double width;
private double height; Class Capsule
Output
num = 100
ch = Z