SlideShare a Scribd company logo
www.webstackacademy.com ‹#›
Java Programming
Language SE – 6
Module 2 : Object-Oriented
Programming
Objectives
● Define object modeling concepts: abstraction,encapsulation and
packages
● Discuss why you can reuse Java technology application code
● Define class, member, attribute, method, constructor, and package
● Use the access modifiers private and public as appropriate for the
guidelines of encapsulation
● Invoke a method on a particular object
● Use the Java technology application programming interface (API)
online documentation
Relevance
● What is your understanding of software analysis and design?
● What is your understanding of design and code reuse?
● What features does the Java programming language possess that
make it an object-oriented language?
● Define the term object-oriented.
Software Engineering
The Analysis and
Design Phase
● Analysis describes what the system needs to do:
Modeling the real-world, including actors and activities, objects,
and behaviors
● Design describes how the system does it:
– Modeling the relationships and interactions between objects and
actors in the system
– Finding useful abstractions to help simplify the problem or
solution
Abstraction
● Functions – Write an algorithm once to be used in many situations
● Objects – Group a related set of attributes and behaviors into a class
● Frameworks and APIs – Large groups of objects that support a
complex activity; Frameworks can be used as is or be modified to
extend the basic behavior
Classes as Blueprints for
Objects
● In manufacturing, a blueprint describes a device from which many
physical devices are constructed.
● In software, a class is a description of an object:
– A class describes the data that each object includes.
– A class describes the behaviors that each object
exhibits.
Classes as Blueprints for
Objects
● In Java technology, classes support three key features of object-
oriented programming (OOP):
– Encapsulation
– Inheritance
– Polymorphism
Declaring Java Technology
Classes
● Basic syntax of a Java class:
<modifier>* class <class_name> {
<attribute_declaration>*
<constructor_declaration>*
<method_declaration>*
}
Declaring Java Technology
Classes
public class Vehicle {
private double maxLoad;
public void setMaxLoad(double value) {
maxLoad = value;
}
}
Declaring Attributes
●
Basic syntax of an attribute:
<modifier>* <type> <name> [ = <initial_value>];
●
Examples:
public class Foo {
private int x;
private float y = 10000.0F;
private String name = "Bates Motel";
}
Declaring Methods
Basic syntax of a method:
<modifier>* <return_type> <name> ( <argument>* ) {
<statement>*
}
Declaring Methods
public class car{
private int modelno;
private String colour;
public void dispInfo(int mno,String col) {
modelno=mno;
colour=col;
}
}
Declaring Methods
Example-2
public class Dog {
private int weight;
public int getWeight() {
return weight;
}
public void setWeight(int newWeight) {
if ( newWeight > 0 ) {
weight = newWeight;
}
}
Accessing Object Members
● The dot notation is: <object>.<member>
● This is used to access object members, including attributes and
methods.
● Examples of dot notation are:
● a.dispInfo(101,”green”);
● a.modelno=”101”;
Example
// create a class car that will display the model number and
colour of car.
class car
{
int modelno;
String colour;
void dispInfo(int mno,String col)
{
modelno = mno;
colour = col;
}
}
Example -2
class carTest
{
car c1=new car();
c1.dispInfo(101,”green”);
}
}
Encapsulation
● Hides the implementation details of a class
● Forces the user to use an interface to access data
● Makes the code more maintainable
CarCar
colour String
model_no int
disp_info() void
Move() void
Declaring Constructors
●
Basic syntax of a constructor:
[<modifier>] <class_name> ( <argument>* ) {
<statement>*
}
●
Example:
public class Car {
private int speed;
public Car() {
speed = 50;
}
}
The Default Constructor
● There is always at least one constructor in every class.
● If the writer does not supply any constructors, the default
constructor is present automatically:
– The default constructor takes no arguments
– The default constructor body is empty
● The default enables you to create object instances with new
Xxx()without having to write a constructor.
Source File Layout
● Basic syntax of a Java source file is:
[<package_declaration>]
<import_declaration>*
<class_declaration>+
Source File Layout
package shipping.reports;
import shipping.domain.*;
import java.util.List;
import java.io.*;
public class VehicleCapacityReport {
private List vehicles;
public void generateReport(Writer output) {...}
}
Software Packages
● Packages help manage large software systems.
● Packages can contain classes and sub-packages.
The package Statement
●
Basic syntax of the package statement is: package
– <top_pkg_name>[.<sub_pkg_name>]*;
●
Examples of the statement are:
– package shipping.gui.reportscreens;
●
Specify the package declaration at the beginning of the source file.
●
Only one package declaration per source file.
●
If no package is declared, then the class is placed into the default
package.
●
Package names must be hierarchical and separated by dots.
The import Statement
● Basic syntax of the import statement is:
Import<pkg_name>[.<sub_pkg_name>]*.<class_name>;
OR
import<pkg_name>[.<sub_pkg_name>]*.*;
● Examples of the statement are:
import java.util.List;
import java.io.*;
import shipping.gui.reportscreens.*;
The import Statement
The import statement does the following:
● Precedes all class declarations
● Tells the compiler where to find classes
Compiling Using the -d
Option
cd JavaProjects/ShippingPrj/src
javac -d ../classes shipping/domain/*.java
Recap
● Class – The source-code blueprint for a run-time object
● Object – An instance of a class;
also known as instance
● Attribute – A data element of an object;
also known as data member, instance variable, and data field
● Method – A behavioral element of an object;
also known as algorithm, function, and procedure
Recap
● Constructor – A method-like construct used to initialize a new object
● Package – A grouping of classes and sub-packages
Java Technology API
Documentation
● A set of Hypertext Markup Language (HTML) files provides
information about the API.
● A frame describes a package and contains hyperlinks to information
describing each class in that package.
● A class document includes the class hierarchy, a description of the
class, a list of member variables, a list of constructors, and so on.
Java Technology API
Documentation
Thank You

More Related Content

What's hot

Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
PravinYalameli
 
Framework prototype
Framework prototypeFramework prototype
Framework prototype
DevMix
 
Presentation on class and object in Object Oriented programming.
Presentation on class and object in Object Oriented programming.Presentation on class and object in Object Oriented programming.
Presentation on class and object in Object Oriented programming.
Enam Khan
 
OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
baabtra.com - No. 1 supplier of quality freshers
 
PHP- Introduction to Object Oriented PHP
PHP-  Introduction to Object Oriented PHPPHP-  Introduction to Object Oriented PHP
PHP- Introduction to Object Oriented PHP
Vibrant Technologies & Computers
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
Professional Guru
 
Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]
Palak Sanghani
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
eMexo Technologies
 
Only oop
Only oopOnly oop
Only oop
anitarooge
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
Danairat Thanabodithammachari
 
JAVA PROGRAMMING- Exception handling - Multithreading
JAVA PROGRAMMING- Exception handling - MultithreadingJAVA PROGRAMMING- Exception handling - Multithreading
JAVA PROGRAMMING- Exception handling - Multithreading
Jyothishmathi Institute of Technology and Science Karimnagar
 
Packages in java
Packages in javaPackages in java
Packages in java
Jancypriya M
 
Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
Govt. P.G. College Dharamshala
 
javapackage
javapackagejavapackage
javapackage
Arjun Shanka
 
CLTL python course: Object Oriented Programming (1/3)
CLTL python course: Object Oriented Programming (1/3)CLTL python course: Object Oriented Programming (1/3)
CLTL python course: Object Oriented Programming (1/3)
Rubén Izquierdo Beviá
 
How to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programmingHow to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programming
Syed Faizan Hassan
 
OCA JAVA - 1 Packages and Class Structure
 OCA JAVA - 1 Packages and Class Structure OCA JAVA - 1 Packages and Class Structure
OCA JAVA - 1 Packages and Class Structure
Fernando Gil
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methods
farhan amjad
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
Mohammed Saleh
 

What's hot (19)

Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
 
Framework prototype
Framework prototypeFramework prototype
Framework prototype
 
Presentation on class and object in Object Oriented programming.
Presentation on class and object in Object Oriented programming.Presentation on class and object in Object Oriented programming.
Presentation on class and object in Object Oriented programming.
 
OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
 
PHP- Introduction to Object Oriented PHP
PHP-  Introduction to Object Oriented PHPPHP-  Introduction to Object Oriented PHP
PHP- Introduction to Object Oriented PHP
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
 
Only oop
Only oopOnly oop
Only oop
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 
JAVA PROGRAMMING- Exception handling - Multithreading
JAVA PROGRAMMING- Exception handling - MultithreadingJAVA PROGRAMMING- Exception handling - Multithreading
JAVA PROGRAMMING- Exception handling - Multithreading
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
 
javapackage
javapackagejavapackage
javapackage
 
CLTL python course: Object Oriented Programming (1/3)
CLTL python course: Object Oriented Programming (1/3)CLTL python course: Object Oriented Programming (1/3)
CLTL python course: Object Oriented Programming (1/3)
 
How to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programmingHow to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programming
 
OCA JAVA - 1 Packages and Class Structure
 OCA JAVA - 1 Packages and Class Structure OCA JAVA - 1 Packages and Class Structure
OCA JAVA - 1 Packages and Class Structure
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methods
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 

Similar to Core Java Programming Language (JSE) : Chapter II - Object Oriented Programming.

Java Tutorial 1
Java Tutorial 1Java Tutorial 1
Java Tutorial 1
Tushar Desarda
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
ciklum_ods
 
java basic for begginers
java basic for begginersjava basic for begginers
java basic for begginers
divaskrgupta007
 
Core Java Programming Language (JSE) : Chapter VII - Advanced Class Features
Core Java Programming Language (JSE) : Chapter VII - Advanced Class FeaturesCore Java Programming Language (JSE) : Chapter VII - Advanced Class Features
Core Java Programming Language (JSE) : Chapter VII - Advanced Class Features
WebStackAcademy
 
The cost of learning - advantage of mixer2
The cost of learning - advantage of mixer2The cost of learning - advantage of mixer2
The cost of learning - advantage of mixer2
Y Watanabe
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09
Bastian Feder
 
1_JavIntro
1_JavIntro1_JavIntro
1_JavIntro
SARJERAO Sarju
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010
Bastian Feder
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
Jay Patel
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the Beast
Bastian Feder
 
Spring 3 to 4
Spring 3 to 4Spring 3 to 4
Spring 3 to 4
Sumit Gole
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructor
Shivam Singhal
 
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKEric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
GuardSquare
 
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon Berlin
 
Building maintainable javascript applications
Building maintainable javascript applicationsBuilding maintainable javascript applications
Building maintainable javascript applications
equisodie
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)
David McCarter
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
 
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Antonio Peric-Mazar
 
Clean code and refactoring
Clean code and refactoringClean code and refactoring
Clean code and refactoring
Yuriy Gerasimov
 
Eclipse Day India 2011 - Extending JDT
Eclipse Day India 2011 - Extending JDTEclipse Day India 2011 - Extending JDT
Eclipse Day India 2011 - Extending JDT
deepakazad
 

Similar to Core Java Programming Language (JSE) : Chapter II - Object Oriented Programming. (20)

Java Tutorial 1
Java Tutorial 1Java Tutorial 1
Java Tutorial 1
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
java basic for begginers
java basic for begginersjava basic for begginers
java basic for begginers
 
Core Java Programming Language (JSE) : Chapter VII - Advanced Class Features
Core Java Programming Language (JSE) : Chapter VII - Advanced Class FeaturesCore Java Programming Language (JSE) : Chapter VII - Advanced Class Features
Core Java Programming Language (JSE) : Chapter VII - Advanced Class Features
 
The cost of learning - advantage of mixer2
The cost of learning - advantage of mixer2The cost of learning - advantage of mixer2
The cost of learning - advantage of mixer2
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09
 
1_JavIntro
1_JavIntro1_JavIntro
1_JavIntro
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the Beast
 
Spring 3 to 4
Spring 3 to 4Spring 3 to 4
Spring 3 to 4
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructor
 
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKEric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
 
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
 
Building maintainable javascript applications
Building maintainable javascript applicationsBuilding maintainable javascript applications
Building maintainable javascript applications
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
 
Clean code and refactoring
Clean code and refactoringClean code and refactoring
Clean code and refactoring
 
Eclipse Day India 2011 - Extending JDT
Eclipse Day India 2011 - Extending JDTEclipse Day India 2011 - Extending JDT
Eclipse Day India 2011 - Extending JDT
 

More from WebStackAcademy

Webstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement JourneyWebstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement Journey
WebStackAcademy
 
WSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per SecondWSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per Second
WebStackAcademy
 
WSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer CourseWSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer Course
WebStackAcademy
 
Career Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and Opportunities
WebStackAcademy
 
Webstack Academy - Internship Kick Off
Webstack Academy - Internship Kick OffWebstack Academy - Internship Kick Off
Webstack Academy - Internship Kick Off
WebStackAcademy
 
Building Your Online Portfolio
Building Your Online PortfolioBuilding Your Online Portfolio
Building Your Online Portfolio
WebStackAcademy
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
WebStackAcademy
 
Angular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and AuthorizationAngular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and Authorization
WebStackAcademy
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
WebStackAcademy
 
Angular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationAngular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase Integration
WebStackAcademy
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
WebStackAcademy
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
WebStackAcademy
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
WebStackAcademy
 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and Arrays
WebStackAcademy
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging Techniques
WebStackAcademy
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
WebStackAcademy
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 

More from WebStackAcademy (20)

Webstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement JourneyWebstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement Journey
 
WSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per SecondWSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per Second
 
WSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer CourseWSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer Course
 
Career Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and Opportunities
 
Webstack Academy - Internship Kick Off
Webstack Academy - Internship Kick OffWebstack Academy - Internship Kick Off
Webstack Academy - Internship Kick Off
 
Building Your Online Portfolio
Building Your Online PortfolioBuilding Your Online Portfolio
Building Your Online Portfolio
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
 
Angular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and AuthorizationAngular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and Authorization
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Angular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationAngular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase Integration
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and Arrays
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging Techniques
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 

Recently uploaded

MESH IPL 2024 REport_Wavemaker India.pdf
MESH IPL 2024 REport_Wavemaker India.pdfMESH IPL 2024 REport_Wavemaker India.pdf
MESH IPL 2024 REport_Wavemaker India.pdf
Social Samosa
 
Spain vs Croatia Spain aims to put aside the RFEF crisis as they chase Euro C...
Spain vs Croatia Spain aims to put aside the RFEF crisis as they chase Euro C...Spain vs Croatia Spain aims to put aside the RFEF crisis as they chase Euro C...
Spain vs Croatia Spain aims to put aside the RFEF crisis as they chase Euro C...
Eticketing.co
 
Belgium vs Romania Ultimate Guide to Euro Cup 2024 Tactics, Ticketing, and Qu...
Belgium vs Romania Ultimate Guide to Euro Cup 2024 Tactics, Ticketing, and Qu...Belgium vs Romania Ultimate Guide to Euro Cup 2024 Tactics, Ticketing, and Qu...
Belgium vs Romania Ultimate Guide to Euro Cup 2024 Tactics, Ticketing, and Qu...
Eticketing.co
 
Psaroudakis: Family and Football – The Psaroudakis Success Story
Psaroudakis: Family and Football – The Psaroudakis Success StoryPsaroudakis: Family and Football – The Psaroudakis Success Story
Psaroudakis: Family and Football – The Psaroudakis Success Story
Psaroudakis
 
真实可查(uofo毕业证书)俄勒冈大学毕业证学位证书范本原版一模一样
真实可查(uofo毕业证书)俄勒冈大学毕业证学位证书范本原版一模一样真实可查(uofo毕业证书)俄勒冈大学毕业证学位证书范本原版一模一样
真实可查(uofo毕业证书)俄勒冈大学毕业证学位证书范本原版一模一样
ra9gairo
 
Georgia vs Portugal Georgia UEFA Euro 2024 Squad Khvicha Kvaratskhelia Leads ...
Georgia vs Portugal Georgia UEFA Euro 2024 Squad Khvicha Kvaratskhelia Leads ...Georgia vs Portugal Georgia UEFA Euro 2024 Squad Khvicha Kvaratskhelia Leads ...
Georgia vs Portugal Georgia UEFA Euro 2024 Squad Khvicha Kvaratskhelia Leads ...
Eticketing.co
 
Netherlands vs Austria Netherlands Face Familiar Foes in Euro Cup Germany Gro...
Netherlands vs Austria Netherlands Face Familiar Foes in Euro Cup Germany Gro...Netherlands vs Austria Netherlands Face Familiar Foes in Euro Cup Germany Gro...
Netherlands vs Austria Netherlands Face Familiar Foes in Euro Cup Germany Gro...
Eticketing.co
 
Match By Match Detailed Schedule Of The ICC Men's T20 World Cup 2024.pdf
Match By Match Detailed Schedule Of The ICC Men's T20 World Cup 2024.pdfMatch By Match Detailed Schedule Of The ICC Men's T20 World Cup 2024.pdf
Match By Match Detailed Schedule Of The ICC Men's T20 World Cup 2024.pdf
mouthhunt5
 
Understanding Golf Simulator Equipment A Beginner's Guide.pdf
Understanding Golf Simulator Equipment A Beginner's Guide.pdfUnderstanding Golf Simulator Equipment A Beginner's Guide.pdf
Understanding Golf Simulator Equipment A Beginner's Guide.pdf
My Garage Golf
 
Tennis rules and techniques with information
Tennis rules and techniques with informationTennis rules and techniques with information
Tennis rules and techniques with information
mohsintariq167876
 
Luciano Spalletti Leads Italy's Transition at UEFA Euro 2024.docx
Luciano Spalletti Leads Italy's Transition at UEFA Euro 2024.docxLuciano Spalletti Leads Italy's Transition at UEFA Euro 2024.docx
Luciano Spalletti Leads Italy's Transition at UEFA Euro 2024.docx
Euro Cup 2024 Tickets
 
Belgium vs Romania Injuries and Patience in Belgium’s Euro Cup Germany Squad....
Belgium vs Romania Injuries and Patience in Belgium’s Euro Cup Germany Squad....Belgium vs Romania Injuries and Patience in Belgium’s Euro Cup Germany Squad....
Belgium vs Romania Injuries and Patience in Belgium’s Euro Cup Germany Squad....
Eticketing.co
 
Turkey vs Georgia Tickets: Turkey's Provisional Squad for UEFA Euro 2024, Key...
Turkey vs Georgia Tickets: Turkey's Provisional Squad for UEFA Euro 2024, Key...Turkey vs Georgia Tickets: Turkey's Provisional Squad for UEFA Euro 2024, Key...
Turkey vs Georgia Tickets: Turkey's Provisional Squad for UEFA Euro 2024, Key...
Eticketing.co
 
Spain vs Croatia Euro 2024 Spain's Chance to Shine on the International Stage...
Spain vs Croatia Euro 2024 Spain's Chance to Shine on the International Stage...Spain vs Croatia Euro 2024 Spain's Chance to Shine on the International Stage...
Spain vs Croatia Euro 2024 Spain's Chance to Shine on the International Stage...
Eticketing.co
 
Gabriel Kalembo A Rising Star in the World of Football Coaching
Gabriel Kalembo A Rising Star in the World of Football CoachingGabriel Kalembo A Rising Star in the World of Football Coaching
Gabriel Kalembo A Rising Star in the World of Football Coaching
gabrielkalembous
 
CAA Region II Day 1 Morning Result Accra event
CAA Region II Day 1 Morning Result Accra eventCAA Region II Day 1 Morning Result Accra event
CAA Region II Day 1 Morning Result Accra event
Kweku Zurek
 
JORNADA 10 LIGA MURO 2024BASQUETBOL1.pdf
JORNADA 10 LIGA MURO 2024BASQUETBOL1.pdfJORNADA 10 LIGA MURO 2024BASQUETBOL1.pdf
JORNADA 10 LIGA MURO 2024BASQUETBOL1.pdf
Arturo Pacheco Alvarez
 
Croatia vs Italy Modric's Last Dance Croatia's UEFA Euro 2024 Journey and Ita...
Croatia vs Italy Modric's Last Dance Croatia's UEFA Euro 2024 Journey and Ita...Croatia vs Italy Modric's Last Dance Croatia's UEFA Euro 2024 Journey and Ita...
Croatia vs Italy Modric's Last Dance Croatia's UEFA Euro 2024 Journey and Ita...
Eticketing.co
 
Italy vs Albania Soul and sacrifice' are the keys to success for Albania at E...
Italy vs Albania Soul and sacrifice' are the keys to success for Albania at E...Italy vs Albania Soul and sacrifice' are the keys to success for Albania at E...
Italy vs Albania Soul and sacrifice' are the keys to success for Albania at E...
Eticketing.co
 
Hesan Soufi's Legacy: Inspiring the Next Generation
Hesan Soufi's Legacy: Inspiring the Next GenerationHesan Soufi's Legacy: Inspiring the Next Generation
Hesan Soufi's Legacy: Inspiring the Next Generation
Hesan Soufi 
 

Recently uploaded (20)

MESH IPL 2024 REport_Wavemaker India.pdf
MESH IPL 2024 REport_Wavemaker India.pdfMESH IPL 2024 REport_Wavemaker India.pdf
MESH IPL 2024 REport_Wavemaker India.pdf
 
Spain vs Croatia Spain aims to put aside the RFEF crisis as they chase Euro C...
Spain vs Croatia Spain aims to put aside the RFEF crisis as they chase Euro C...Spain vs Croatia Spain aims to put aside the RFEF crisis as they chase Euro C...
Spain vs Croatia Spain aims to put aside the RFEF crisis as they chase Euro C...
 
Belgium vs Romania Ultimate Guide to Euro Cup 2024 Tactics, Ticketing, and Qu...
Belgium vs Romania Ultimate Guide to Euro Cup 2024 Tactics, Ticketing, and Qu...Belgium vs Romania Ultimate Guide to Euro Cup 2024 Tactics, Ticketing, and Qu...
Belgium vs Romania Ultimate Guide to Euro Cup 2024 Tactics, Ticketing, and Qu...
 
Psaroudakis: Family and Football – The Psaroudakis Success Story
Psaroudakis: Family and Football – The Psaroudakis Success StoryPsaroudakis: Family and Football – The Psaroudakis Success Story
Psaroudakis: Family and Football – The Psaroudakis Success Story
 
真实可查(uofo毕业证书)俄勒冈大学毕业证学位证书范本原版一模一样
真实可查(uofo毕业证书)俄勒冈大学毕业证学位证书范本原版一模一样真实可查(uofo毕业证书)俄勒冈大学毕业证学位证书范本原版一模一样
真实可查(uofo毕业证书)俄勒冈大学毕业证学位证书范本原版一模一样
 
Georgia vs Portugal Georgia UEFA Euro 2024 Squad Khvicha Kvaratskhelia Leads ...
Georgia vs Portugal Georgia UEFA Euro 2024 Squad Khvicha Kvaratskhelia Leads ...Georgia vs Portugal Georgia UEFA Euro 2024 Squad Khvicha Kvaratskhelia Leads ...
Georgia vs Portugal Georgia UEFA Euro 2024 Squad Khvicha Kvaratskhelia Leads ...
 
Netherlands vs Austria Netherlands Face Familiar Foes in Euro Cup Germany Gro...
Netherlands vs Austria Netherlands Face Familiar Foes in Euro Cup Germany Gro...Netherlands vs Austria Netherlands Face Familiar Foes in Euro Cup Germany Gro...
Netherlands vs Austria Netherlands Face Familiar Foes in Euro Cup Germany Gro...
 
Match By Match Detailed Schedule Of The ICC Men's T20 World Cup 2024.pdf
Match By Match Detailed Schedule Of The ICC Men's T20 World Cup 2024.pdfMatch By Match Detailed Schedule Of The ICC Men's T20 World Cup 2024.pdf
Match By Match Detailed Schedule Of The ICC Men's T20 World Cup 2024.pdf
 
Understanding Golf Simulator Equipment A Beginner's Guide.pdf
Understanding Golf Simulator Equipment A Beginner's Guide.pdfUnderstanding Golf Simulator Equipment A Beginner's Guide.pdf
Understanding Golf Simulator Equipment A Beginner's Guide.pdf
 
Tennis rules and techniques with information
Tennis rules and techniques with informationTennis rules and techniques with information
Tennis rules and techniques with information
 
Luciano Spalletti Leads Italy's Transition at UEFA Euro 2024.docx
Luciano Spalletti Leads Italy's Transition at UEFA Euro 2024.docxLuciano Spalletti Leads Italy's Transition at UEFA Euro 2024.docx
Luciano Spalletti Leads Italy's Transition at UEFA Euro 2024.docx
 
Belgium vs Romania Injuries and Patience in Belgium’s Euro Cup Germany Squad....
Belgium vs Romania Injuries and Patience in Belgium’s Euro Cup Germany Squad....Belgium vs Romania Injuries and Patience in Belgium’s Euro Cup Germany Squad....
Belgium vs Romania Injuries and Patience in Belgium’s Euro Cup Germany Squad....
 
Turkey vs Georgia Tickets: Turkey's Provisional Squad for UEFA Euro 2024, Key...
Turkey vs Georgia Tickets: Turkey's Provisional Squad for UEFA Euro 2024, Key...Turkey vs Georgia Tickets: Turkey's Provisional Squad for UEFA Euro 2024, Key...
Turkey vs Georgia Tickets: Turkey's Provisional Squad for UEFA Euro 2024, Key...
 
Spain vs Croatia Euro 2024 Spain's Chance to Shine on the International Stage...
Spain vs Croatia Euro 2024 Spain's Chance to Shine on the International Stage...Spain vs Croatia Euro 2024 Spain's Chance to Shine on the International Stage...
Spain vs Croatia Euro 2024 Spain's Chance to Shine on the International Stage...
 
Gabriel Kalembo A Rising Star in the World of Football Coaching
Gabriel Kalembo A Rising Star in the World of Football CoachingGabriel Kalembo A Rising Star in the World of Football Coaching
Gabriel Kalembo A Rising Star in the World of Football Coaching
 
CAA Region II Day 1 Morning Result Accra event
CAA Region II Day 1 Morning Result Accra eventCAA Region II Day 1 Morning Result Accra event
CAA Region II Day 1 Morning Result Accra event
 
JORNADA 10 LIGA MURO 2024BASQUETBOL1.pdf
JORNADA 10 LIGA MURO 2024BASQUETBOL1.pdfJORNADA 10 LIGA MURO 2024BASQUETBOL1.pdf
JORNADA 10 LIGA MURO 2024BASQUETBOL1.pdf
 
Croatia vs Italy Modric's Last Dance Croatia's UEFA Euro 2024 Journey and Ita...
Croatia vs Italy Modric's Last Dance Croatia's UEFA Euro 2024 Journey and Ita...Croatia vs Italy Modric's Last Dance Croatia's UEFA Euro 2024 Journey and Ita...
Croatia vs Italy Modric's Last Dance Croatia's UEFA Euro 2024 Journey and Ita...
 
Italy vs Albania Soul and sacrifice' are the keys to success for Albania at E...
Italy vs Albania Soul and sacrifice' are the keys to success for Albania at E...Italy vs Albania Soul and sacrifice' are the keys to success for Albania at E...
Italy vs Albania Soul and sacrifice' are the keys to success for Albania at E...
 
Hesan Soufi's Legacy: Inspiring the Next Generation
Hesan Soufi's Legacy: Inspiring the Next GenerationHesan Soufi's Legacy: Inspiring the Next Generation
Hesan Soufi's Legacy: Inspiring the Next Generation
 

Core Java Programming Language (JSE) : Chapter II - Object Oriented Programming.

  • 1. www.webstackacademy.com ‹#› Java Programming Language SE – 6 Module 2 : Object-Oriented Programming
  • 2. Objectives ● Define object modeling concepts: abstraction,encapsulation and packages ● Discuss why you can reuse Java technology application code ● Define class, member, attribute, method, constructor, and package ● Use the access modifiers private and public as appropriate for the guidelines of encapsulation ● Invoke a method on a particular object ● Use the Java technology application programming interface (API) online documentation
  • 3. Relevance ● What is your understanding of software analysis and design? ● What is your understanding of design and code reuse? ● What features does the Java programming language possess that make it an object-oriented language? ● Define the term object-oriented.
  • 5. The Analysis and Design Phase ● Analysis describes what the system needs to do: Modeling the real-world, including actors and activities, objects, and behaviors ● Design describes how the system does it: – Modeling the relationships and interactions between objects and actors in the system – Finding useful abstractions to help simplify the problem or solution
  • 6. Abstraction ● Functions – Write an algorithm once to be used in many situations ● Objects – Group a related set of attributes and behaviors into a class ● Frameworks and APIs – Large groups of objects that support a complex activity; Frameworks can be used as is or be modified to extend the basic behavior
  • 7. Classes as Blueprints for Objects ● In manufacturing, a blueprint describes a device from which many physical devices are constructed. ● In software, a class is a description of an object: – A class describes the data that each object includes. – A class describes the behaviors that each object exhibits.
  • 8. Classes as Blueprints for Objects ● In Java technology, classes support three key features of object- oriented programming (OOP): – Encapsulation – Inheritance – Polymorphism
  • 9. Declaring Java Technology Classes ● Basic syntax of a Java class: <modifier>* class <class_name> { <attribute_declaration>* <constructor_declaration>* <method_declaration>* }
  • 10. Declaring Java Technology Classes public class Vehicle { private double maxLoad; public void setMaxLoad(double value) { maxLoad = value; } }
  • 11. Declaring Attributes ● Basic syntax of an attribute: <modifier>* <type> <name> [ = <initial_value>]; ● Examples: public class Foo { private int x; private float y = 10000.0F; private String name = "Bates Motel"; }
  • 12. Declaring Methods Basic syntax of a method: <modifier>* <return_type> <name> ( <argument>* ) { <statement>* }
  • 13. Declaring Methods public class car{ private int modelno; private String colour; public void dispInfo(int mno,String col) { modelno=mno; colour=col; } }
  • 14. Declaring Methods Example-2 public class Dog { private int weight; public int getWeight() { return weight; } public void setWeight(int newWeight) { if ( newWeight > 0 ) { weight = newWeight; } }
  • 15. Accessing Object Members ● The dot notation is: <object>.<member> ● This is used to access object members, including attributes and methods. ● Examples of dot notation are: ● a.dispInfo(101,”green”); ● a.modelno=”101”;
  • 16. Example // create a class car that will display the model number and colour of car. class car { int modelno; String colour; void dispInfo(int mno,String col) { modelno = mno; colour = col; } }
  • 17. Example -2 class carTest { car c1=new car(); c1.dispInfo(101,”green”); } }
  • 18. Encapsulation ● Hides the implementation details of a class ● Forces the user to use an interface to access data ● Makes the code more maintainable CarCar colour String model_no int disp_info() void Move() void
  • 19. Declaring Constructors ● Basic syntax of a constructor: [<modifier>] <class_name> ( <argument>* ) { <statement>* } ● Example: public class Car { private int speed; public Car() { speed = 50; } }
  • 20. The Default Constructor ● There is always at least one constructor in every class. ● If the writer does not supply any constructors, the default constructor is present automatically: – The default constructor takes no arguments – The default constructor body is empty ● The default enables you to create object instances with new Xxx()without having to write a constructor.
  • 21. Source File Layout ● Basic syntax of a Java source file is: [<package_declaration>] <import_declaration>* <class_declaration>+
  • 22. Source File Layout package shipping.reports; import shipping.domain.*; import java.util.List; import java.io.*; public class VehicleCapacityReport { private List vehicles; public void generateReport(Writer output) {...} }
  • 23. Software Packages ● Packages help manage large software systems. ● Packages can contain classes and sub-packages.
  • 24. The package Statement ● Basic syntax of the package statement is: package – <top_pkg_name>[.<sub_pkg_name>]*; ● Examples of the statement are: – package shipping.gui.reportscreens; ● Specify the package declaration at the beginning of the source file. ● Only one package declaration per source file. ● If no package is declared, then the class is placed into the default package. ● Package names must be hierarchical and separated by dots.
  • 25. The import Statement ● Basic syntax of the import statement is: Import<pkg_name>[.<sub_pkg_name>]*.<class_name>; OR import<pkg_name>[.<sub_pkg_name>]*.*; ● Examples of the statement are: import java.util.List; import java.io.*; import shipping.gui.reportscreens.*;
  • 26. The import Statement The import statement does the following: ● Precedes all class declarations ● Tells the compiler where to find classes
  • 27. Compiling Using the -d Option cd JavaProjects/ShippingPrj/src javac -d ../classes shipping/domain/*.java
  • 28. Recap ● Class – The source-code blueprint for a run-time object ● Object – An instance of a class; also known as instance ● Attribute – A data element of an object; also known as data member, instance variable, and data field ● Method – A behavioral element of an object; also known as algorithm, function, and procedure
  • 29. Recap ● Constructor – A method-like construct used to initialize a new object ● Package – A grouping of classes and sub-packages
  • 30. Java Technology API Documentation ● A set of Hypertext Markup Language (HTML) files provides information about the API. ● A frame describes a package and contains hyperlinks to information describing each class in that package. ● A class document includes the class hierarchy, a description of the class, a list of member variables, a list of constructors, and so on.