SlideShare a Scribd company logo
CS 213
OBJECT ORIENTED PROGRAMMING
IN JAVA
INSTRUCTORS
• MR. FERUZI HASSAN (0758731369)
• MR. SAID SAID ( 0716995733)
LECTURE
• GROUP A (CE,CIS,CS,ICT_MCD, MTA)
• WEDNSADAY 4.00 – 6.00
• GROUP B(TE,IS, BIS,HIS, SE)
• THURSDAY 2.00- 4.00
• Practical session: refer time table
Assesment Model
• Practical questions and attendance –10 Marks
• Practical test ----- 20 Marks
• Group project work--- 10 Marks
• UE--- 60 Marks
• Any kind of cheating will result to discontinue
from study With 0 tolerance.
outline
• Overview
• Basic syntax
• Environment setup
• Object and Class
• Basic data type
• Variable type
• Modifier type
• Basic operators
outline
• Java loop control
• String
• Arrays
• Date and time
• Method in Java
• Exception
• Inheritance
• Overriding
• Polymorphism
• Abstraction
• Encapsulation
• Interface
• Package
• GUI
Overview
• Java programming language was originally
developed by Sun Microsystems which was
initiated by James Gosling and released in
1995 as core component of Sun Microsystems'
Java platform (Java 1.0 [J2SE])
• Java runs on a variety of platforms, such as
Windows, Mac OS, and the various versions of
UNIX.
Java is −
• Object Oriented − In Java, everything is an
Object.
• Java can be easily extended since it is based
on the Object model.
Java is −
• Platform Independent − Unlike many other
programming languages including C and C++,
when Java is compiled, it is not compiled into
platform specific machine, rather into
platform independent byte code.
• This byte code is distributed over the web and
interpreted by the Virtual Machine (JVM) on
whichever platform it is being run on.
Java is −
• Simple − Java is designed to be easy to learn.
If you understand the basic concept of OOP
Java, it would be easy to master.
Java is −
• Secure − With Java's secure feature it enables
to develop virus-free, tamper-free systems.
Authentication techniques are based on
public-key encryption.
Java - Basic Syntax
• When we consider a Java program, it can be
defined as a collection of objects that
communicate via invoking each other's
methods.
• In the following slides, briefly look into what
do class, object, methods, and instance
variables mean
Java - Basic Syntax
• Object − Objects are entities in a software system
which represent instances of real-world and
system entities
• Objects have states and behaviors. Example: A
dog has states - color, name, breed as well as
behavior such as wagging their tail, barking,
eating.
• An object is an instance of a class.
• Refer to Object-oriented Design: Designing
systems using self-contained objects and object
classes
Java - Basic Syntax
• An object is an entity which has a state and a defined
set of operations which operate on that state. The state
is represented as a set of object attributes. The
operations associated with the object provide services
to other objects (clients) which request these services
when some computation is required.
• Objects are created according to some object class
definition. An object class definition serves as a
template for objects. It includes declarations of all the
attributes and services which should be associated
with an object of that class.
Refer to Object Oriented Software
Design
• Characteristics of OOD
 Objects are abstractions of real-world or system
entities and manage themselves
 Objects are independent and encapsulate state and
representation information.
 System functionality is expressed in terms of object
services
 Shared data areas are eliminated.
 Objects communicate by message passing
 Objects may be distributed and may execute
sequentially or in parallel
Java – Basics of objects
• Interacting objects
state o3
o3:C3
state o4
o4: C4
state o1
o1: C1
state o6
o6: C1
state o5
o5:C5
state o2
o2: C3
ops1() ops3 () ops4 ()
ops3 () ops1 () ops5 ()
The Unified Modelling Language
• Several different notations for object-oriented
designs were proposed in the 1980s
describing and 1990s
• The Unified Modeling Language is an
integration of these notations
• It describes notations for a number of
different models that may be produced during
OO analysis and design
• It is now a de facto standard for OO modelling
The Unified Modeling Language
• Employee object class (UML)
Employee
name: string
address: string
dateOfBirth: Date
employeeNo: integer
socialSecurityNo: string
department: Dept
manager: Employee
salary: integer
status: {current, left, retired}
taxCode: integer
. . .
join ()
leave ()
retire ()
changeDetails ()
Class
• A class can be defined as a template/blueprint
that describes the behavior/state that the
object of its type supports.
• classes may inherit attributes and services
from other classes.
Methods
• A method is basically a behavior. A class can
contain many methods.
• It is in methods where the logics are written,
data is manipulated and all the actions are
executed.
Instance Variables
• Each object has its unique set of instance
variables. An object's state is created by the
values assigned to these instance variables.
First Java Program
public class MyFirstJavaProgram {
/* This is my first java program.
* This will print 'Hello World' as the output */
public static void main(String []args) {
System.out.println("Hello World");
// prints Hello World
} }
First Java Program
it is very important to keep in mind the following
points.
• Case Sensitivity − Java is case sensitive, which
means identifier Hello and hello would have
different meaning in Java.
• Class Names − For all class names the first letter
should be in Upper Case. If several words are
used to form a name of the class, each inner
word's first letter should be in Upper Case.
Example: class MyFirstJavaClass
First Java Program
it is very important to keep in mind the
following points.
• Method Names − All method names should
start with a Lower Case letter. If several words
are used to form the name of the method,
then each inner word's first letter should be in
Upper Case.
• Example: public void myMethodName()
First Java Program
it is very important to keep in mind the following
points.
• Program File Name − Name of the program file should
exactly match the class name.
• When saving the file, you should save it using the class
name (Remember Java is case sensitive) and append
'.java' to the end of the name (if the file name and the
class name do not match, your program will not
compile).
• Example: Assume 'MyFirstJavaProgram' is the class
name. Then the file should be saved
as 'MyFirstJavaProgram.java'
First Java Program
it is very important to keep in mind the
following points.
• public static void main(String args[]) − Java
program processing starts from the main()
method which is a mandatory part of every
Java program
Java Identifiers
• All Java components require names. Names
used for classes, variables, and methods are
called identifiers.
Java Identifiers
In Java, there are several points to remember
about identifiers. They are as follows −
• ll identifiers should begin with a letter (A to Z
or a to z), currency character ($) or an
underscore (_).
• After the first character, identifiers can have
any combination of characters.
• A key word cannot be used as an identifier.
Java Identifiers
In Java, there are several points to remember
about identifiers. They are as follows −
• Most importantly, identifiers are case
sensitive.
• Examples of legal identifiers: age, $salary,
_value, __1_value.
• Examples of illegal identifiers: 123abc, -salary.
Java Keywords
• The following list shows the reserved words in
Java. These reserved words may not be used
as constant or variable or any other identifier
names.
Java Keywords
Comments in Java
• Java supports single-line and multi-line
comments very similar to C and C++.
• All characters available inside any comment
are ignored by Java compiler.
/* This is my first java program.
* This will print 'Hello World' as the output
• This is an example of multi-line comments. */
// This is an example of single line comment
Java Modifiers
• Access modifiers help you set the level of access you
want for your Class, variables as well as Methods.
• Like other languages, it is possible to modify classes,
methods, etc., by using modifiers. There are two
categories of modifiers −
• Access Modifiers − default, public , protected, private
• Non-access Modifiers − final, abstract, strictfp
More detail can be found here:
http://javabeginnerstutorial.com/core-java-tutorial/access-modifier-in-java/
Java Modifiers
• Public: When set to public, the given Class will
be accessible to all the classes available in the
Java world.
• Protected: If a variable is set to protected
inside a Class, it will be accessible from its sub
classes defined in the same or different
package only via Inheritance.
Java Modifiers
• Private: A variable if defined private will be
accessible only from within the Class in which
it is defined. Such variables are not accessible
from outside the defined Class, not even in its
subclass .
Java Access Modifiers Table for
Variable
Java Access Modifiers Table for
Method
Java Variables
• Following are the types of variables in Java −
• Local Variables: Variables that are declared
inside Methods in a Java program are called
local variables.
• Class Variables (Static Variables)
• Instance Variables (Non-static Variables)
Instance variables
• Instance variables are used by Objects to store
their states.
• Variables which are defined without
the STATIC keyword and are Outside any
method declaration are Object specific and
are known as instance variables.
• They are called so because their values are
instance specific and are not shared among
instances.
Instance variables
• Example of Instance Variable
class Page {
public String pageName;
// instance variable with public access
private int pageNumber;
// instance variable with private access
}
cs213Lecture_1 java programming oopsss.pptx

More Related Content

Similar to cs213Lecture_1 java programming oopsss.pptx (20)

PPTX
U1 JAVA.pptx
madan r
 
PPTX
PPT Lecture-1.2 java basics jvm, literals,
shubhamkumar248717
 
PPTX
Java
Zeeshan Khan
 
PPTX
2. Introduction to Java for engineering stud
vyshukodumuri
 
PPTX
CS8392 OOP
DhanalakshmiVelusamy1
 
PPTX
Java basic
Pooja Thakur
 
PDF
Lectupopplkmkmkkpompom-0ookoimmire 2.pdf
rtreduanur247
 
PDF
A seminar report on core java
Aisha Siddiqui
 
PPTX
Java
Raghu nath
 
PPTX
flowchart demasdasddasdsadsadsadasoasd.pptx
lemerdzsison3
 
PPTX
Module 1.pptx
YakaviBalakrishnan
 
PPTX
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
tusharjain613841
 
PPT
java tutorial for beginners learning.ppt
usha852
 
PPT
Java Basics for selenium
apoorvams
 
PPTX
Introduction to java Programming Language
rubyjeyamani1
 
PPTX
intro_java (1).pptx
SmitNikumbh
 
PPTX
Chapter 2 java
Ahmad sohail Kakar
 
PPTX
Module--fundamentals and operators in java1.pptx
Radhika Venkatesh
 
PPTX
Introduction to Software - Coder Forge - John Mulhall
John Mulhall
 
U1 JAVA.pptx
madan r
 
PPT Lecture-1.2 java basics jvm, literals,
shubhamkumar248717
 
2. Introduction to Java for engineering stud
vyshukodumuri
 
Java basic
Pooja Thakur
 
Lectupopplkmkmkkpompom-0ookoimmire 2.pdf
rtreduanur247
 
A seminar report on core java
Aisha Siddiqui
 
flowchart demasdasddasdsadsadsadasoasd.pptx
lemerdzsison3
 
Module 1.pptx
YakaviBalakrishnan
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
tusharjain613841
 
java tutorial for beginners learning.ppt
usha852
 
Java Basics for selenium
apoorvams
 
Introduction to java Programming Language
rubyjeyamani1
 
intro_java (1).pptx
SmitNikumbh
 
Chapter 2 java
Ahmad sohail Kakar
 
Module--fundamentals and operators in java1.pptx
Radhika Venkatesh
 
Introduction to Software - Coder Forge - John Mulhall
John Mulhall
 

Recently uploaded (20)

PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Ad

cs213Lecture_1 java programming oopsss.pptx

  • 1. CS 213 OBJECT ORIENTED PROGRAMMING IN JAVA
  • 2. INSTRUCTORS • MR. FERUZI HASSAN (0758731369) • MR. SAID SAID ( 0716995733)
  • 3. LECTURE • GROUP A (CE,CIS,CS,ICT_MCD, MTA) • WEDNSADAY 4.00 – 6.00 • GROUP B(TE,IS, BIS,HIS, SE) • THURSDAY 2.00- 4.00 • Practical session: refer time table
  • 4. Assesment Model • Practical questions and attendance –10 Marks • Practical test ----- 20 Marks • Group project work--- 10 Marks • UE--- 60 Marks • Any kind of cheating will result to discontinue from study With 0 tolerance.
  • 5. outline • Overview • Basic syntax • Environment setup • Object and Class • Basic data type • Variable type • Modifier type • Basic operators
  • 6. outline • Java loop control • String • Arrays • Date and time • Method in Java • Exception • Inheritance • Overriding • Polymorphism • Abstraction • Encapsulation • Interface • Package • GUI
  • 7. Overview • Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java platform (Java 1.0 [J2SE]) • Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
  • 8. Java is − • Object Oriented − In Java, everything is an Object. • Java can be easily extended since it is based on the Object model.
  • 9. Java is − • Platform Independent − Unlike many other programming languages including C and C++, when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. • This byte code is distributed over the web and interpreted by the Virtual Machine (JVM) on whichever platform it is being run on.
  • 10. Java is − • Simple − Java is designed to be easy to learn. If you understand the basic concept of OOP Java, it would be easy to master.
  • 11. Java is − • Secure − With Java's secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption.
  • 12. Java - Basic Syntax • When we consider a Java program, it can be defined as a collection of objects that communicate via invoking each other's methods. • In the following slides, briefly look into what do class, object, methods, and instance variables mean
  • 13. Java - Basic Syntax • Object − Objects are entities in a software system which represent instances of real-world and system entities • Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behavior such as wagging their tail, barking, eating. • An object is an instance of a class. • Refer to Object-oriented Design: Designing systems using self-contained objects and object classes
  • 14. Java - Basic Syntax • An object is an entity which has a state and a defined set of operations which operate on that state. The state is represented as a set of object attributes. The operations associated with the object provide services to other objects (clients) which request these services when some computation is required. • Objects are created according to some object class definition. An object class definition serves as a template for objects. It includes declarations of all the attributes and services which should be associated with an object of that class.
  • 15. Refer to Object Oriented Software Design • Characteristics of OOD  Objects are abstractions of real-world or system entities and manage themselves  Objects are independent and encapsulate state and representation information.  System functionality is expressed in terms of object services  Shared data areas are eliminated.  Objects communicate by message passing  Objects may be distributed and may execute sequentially or in parallel
  • 16. Java – Basics of objects • Interacting objects state o3 o3:C3 state o4 o4: C4 state o1 o1: C1 state o6 o6: C1 state o5 o5:C5 state o2 o2: C3 ops1() ops3 () ops4 () ops3 () ops1 () ops5 ()
  • 17. The Unified Modelling Language • Several different notations for object-oriented designs were proposed in the 1980s describing and 1990s • The Unified Modeling Language is an integration of these notations • It describes notations for a number of different models that may be produced during OO analysis and design • It is now a de facto standard for OO modelling
  • 18. The Unified Modeling Language • Employee object class (UML) Employee name: string address: string dateOfBirth: Date employeeNo: integer socialSecurityNo: string department: Dept manager: Employee salary: integer status: {current, left, retired} taxCode: integer . . . join () leave () retire () changeDetails ()
  • 19. Class • A class can be defined as a template/blueprint that describes the behavior/state that the object of its type supports. • classes may inherit attributes and services from other classes.
  • 20. Methods • A method is basically a behavior. A class can contain many methods. • It is in methods where the logics are written, data is manipulated and all the actions are executed.
  • 21. Instance Variables • Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables.
  • 22. First Java Program public class MyFirstJavaProgram { /* This is my first java program. * This will print 'Hello World' as the output */ public static void main(String []args) { System.out.println("Hello World"); // prints Hello World } }
  • 23. First Java Program it is very important to keep in mind the following points. • Case Sensitivity − Java is case sensitive, which means identifier Hello and hello would have different meaning in Java. • Class Names − For all class names the first letter should be in Upper Case. If several words are used to form a name of the class, each inner word's first letter should be in Upper Case. Example: class MyFirstJavaClass
  • 24. First Java Program it is very important to keep in mind the following points. • Method Names − All method names should start with a Lower Case letter. If several words are used to form the name of the method, then each inner word's first letter should be in Upper Case. • Example: public void myMethodName()
  • 25. First Java Program it is very important to keep in mind the following points. • Program File Name − Name of the program file should exactly match the class name. • When saving the file, you should save it using the class name (Remember Java is case sensitive) and append '.java' to the end of the name (if the file name and the class name do not match, your program will not compile). • Example: Assume 'MyFirstJavaProgram' is the class name. Then the file should be saved as 'MyFirstJavaProgram.java'
  • 26. First Java Program it is very important to keep in mind the following points. • public static void main(String args[]) − Java program processing starts from the main() method which is a mandatory part of every Java program
  • 27. Java Identifiers • All Java components require names. Names used for classes, variables, and methods are called identifiers.
  • 28. Java Identifiers In Java, there are several points to remember about identifiers. They are as follows − • ll identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_). • After the first character, identifiers can have any combination of characters. • A key word cannot be used as an identifier.
  • 29. Java Identifiers In Java, there are several points to remember about identifiers. They are as follows − • Most importantly, identifiers are case sensitive. • Examples of legal identifiers: age, $salary, _value, __1_value. • Examples of illegal identifiers: 123abc, -salary.
  • 30. Java Keywords • The following list shows the reserved words in Java. These reserved words may not be used as constant or variable or any other identifier names.
  • 32. Comments in Java • Java supports single-line and multi-line comments very similar to C and C++. • All characters available inside any comment are ignored by Java compiler. /* This is my first java program. * This will print 'Hello World' as the output • This is an example of multi-line comments. */ // This is an example of single line comment
  • 33. Java Modifiers • Access modifiers help you set the level of access you want for your Class, variables as well as Methods. • Like other languages, it is possible to modify classes, methods, etc., by using modifiers. There are two categories of modifiers − • Access Modifiers − default, public , protected, private • Non-access Modifiers − final, abstract, strictfp More detail can be found here: http://javabeginnerstutorial.com/core-java-tutorial/access-modifier-in-java/
  • 34. Java Modifiers • Public: When set to public, the given Class will be accessible to all the classes available in the Java world. • Protected: If a variable is set to protected inside a Class, it will be accessible from its sub classes defined in the same or different package only via Inheritance.
  • 35. Java Modifiers • Private: A variable if defined private will be accessible only from within the Class in which it is defined. Such variables are not accessible from outside the defined Class, not even in its subclass .
  • 36. Java Access Modifiers Table for Variable
  • 37. Java Access Modifiers Table for Method
  • 38. Java Variables • Following are the types of variables in Java − • Local Variables: Variables that are declared inside Methods in a Java program are called local variables. • Class Variables (Static Variables) • Instance Variables (Non-static Variables)
  • 39. Instance variables • Instance variables are used by Objects to store their states. • Variables which are defined without the STATIC keyword and are Outside any method declaration are Object specific and are known as instance variables. • They are called so because their values are instance specific and are not shared among instances.
  • 40. Instance variables • Example of Instance Variable class Page { public String pageName; // instance variable with public access private int pageNumber; // instance variable with private access }