Lecture - 2
Lecture - 2
and Algorithms
Java Programming Language
● An object-oriented, high-level language with automatic garbage
collection that follows “Write-Once Run Anywhere” (WORA)
paradigm
○ It is not an interpreted language, but is compiled into an intermediate byte-
code – javac
○ Executed over a “virtual machine” that mediates with the underlying
hardware and the byte-code – java
Java Programming Flow
A Simple Java Program
public class Student {
public String name;
public String entryNum;
public Integer batchNum;
}
Java – Instantiating Objects
public class Student {
public String name;
public String entryNum;
public Integer batchNum;
public static void main (String[] args) {
System.out.println(“Hello World!”);
st1 = new Student();
st1.name = “Veeru”;
st2 = new Student();
st2.name = “Basanti”;
}
}
Goals of Object-oriented Approach
● Robustness
○ We want software to be capable of handling unexpected inputs that are not
explicitly defined for its application.
● Adaptability
○ Software needs to be able to evolve over time in response to changing
conditions in its environment.
● Reusability
○ The same code should be usable as a component of different systems in
various applications.
Core Ideas of Object-Oriented Approach
● Idea 1 : Abstraction
○ We only need to know ”what” needs to be the behavior, not “how” it is
implemented
○ Abstraction is to distill a system to its most fundamental parts.
https://www.fastcompany.com/90320298/these- https://thefairyglitchmother.com/car-
https://en.comun.app/blog/como-usar-cajeros- drawing-for-kids-how-to-make-it-easy-peasy/
oddly-satisfying-photos-reveal-the-inner-workings- automaticos-de-manera-segura-consejos-y-
of-everyday-objects trucos
Core Ideas of Object-Oriented Approach
● Idea 3 : Modularity
○ A large software is divided into separate functional units
○ Each unit has a well-defined functionality (abstracted appropriately) so that
different units can be independently be developed against their functional
abstraction
T : reference to
the object of
the ADT we are
Not all ADTs allow “mutator” operations working with
Mutable and Immutable ADTs
A SimpleString ADT
SimpleString Implementation - 1
SimpleString Implementation - 1