SlideShare a Scribd company logo
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
What is Hadoop?
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Agenda For Today
➢ What is a Class?
➢ Constructors
➢ Structure of a Class
➢ Overview of objects
➢ Working with objects
➢ Using Multiple classes
➢ OOPS concepts
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
What is a Class?
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
What is a Class?
 A class in java is a blueprint which includes all the data.
 It describes the state and behavior of a specific object.
Classes
Example :
Public class car {
Color
Model
Price
speedUp();
gearChange();
}
Syntax :
Variables
Class name
Car
Methods
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Member Variables
Member variables are used to store a data value
Types
Class variableInstance variableLocal variable
Member
variables
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Types of Variables
Local variable Instance variable Class variable
Local variables are declared
within the method of a class
Instance variable are declared in a
class but outside a method,
constructor or any block
Class / static variable has only one
copy that is shared by all the
different objects of a class
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Methods
 Describes the behavior of an object.
 Collection of statements that are grouped together to perform an operation.
Methods
Example : Name of the method
Functionality
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Constructors
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Constructors
 Block of code used to initialize an object
 Must have same name of the class
 No return type
 Automatically called when an object is created
Constructors
Type of Constructors
Default Constructor
Parameterized
Constructor
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Types of Constructors
➢ No argument
➢ Compiler provides default value, automatically created
➢ Accept arguments
➢ Provides different value to objects
Default Parameterized
Example : Example :
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Access Modifiers
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Access Modifiers
Public Private
Protected Default
Access Modifiers
Class, methods, variables and
constructors can be accessed from
any other class.
No modifier required. Access class,
variables, method in same package
but not from outside.
Methods, variables and constructors
are declared protected in a
superclass can be accessed only by
the subclasses.
Methods, variables and constructors
can only be accessed within the
declared class.
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Access Modifiers
Access Modifiers Same Class Same Package Sub Class Other Packages
Public Y Y Y Y
Private Y N N N
Protected Y Y Y N
Default Y Y N N
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Structure of Classes
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Structure of Classes
Constructor
Member variables
Method
Name of the Class
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Overview of Objects
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Overview of Objects
 It is an entity that has state and behavior
 Instance of a class which can access data
Objects
➢ States of a Car : Color - Orange
Model - 1
Price - 50000
➢ Behavior of Car : Speed up
Change gear
Class - Car
(Blueprint )
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Working with Objects
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
InitializationInstantiationDeclaration
Working with Objects
Variable name
with a data type
“New” keyword
creates an object
Call to a constructor,
initializes new object
How can you create an object?
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Working with Objects
Syntax :
 Objects to a class is created by using the keyword “new”.
 New allocates memory for the object.
Student student1 = new Student();
Object Name
Class Name Keyword
Constructor
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Working with Objects
Store data into object using a
constructor
Constructor
Stores data into objects by
invoking a method.
Method
Stores data into object through
reference variable
Reference
variable
Initialize an object?
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Working with Multiple Classes
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Working with Multiple Classes
Constructor of Class A
Method of class A
Constructor of class B
Method of class B
Output :
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
OOPS Concepts
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Inheritance
 One class acquire properties (methods & fields) of another
 Class which inherits the properties – Child class/ derived class/ sub class
 Class whose properties are inherited – Parent class/ base class
Inheritance
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Types of Inheritance
Inheritance
Single HierarchicalMultilevel Hybrid
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Class B inherits the properties of A
Inheritance
Class A {
----
}
Public class B extends A {
----
----
}
Syntax:
Single
Hierarchical
Multilevel
Hybrid
Class A
Class B
Parent Class
Child class of A
Single
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Inheritance
Class A
Class B
Class C
Class A {
----
}
public class B extends A {
---
}
Public class C extends B {
---
}
Syntax:
Single
Hierarchical
Multilevel
Hybrid
Class B inherits the properties of A and Class B inherits the
properties of B
Parent class of B
Parent class of C
Child class of A
Child class of B
Multilevel
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Inheritance
Class A
Class B Class C
Class A {
----
}
public class B extends A {
----
}
Public class C extends A {
----
}
Syntax:
Single
Hierarchical
Multilevel
Hybrid
One class is inherited by many subclasses
Parent Class
Child Classes
Hierarchical
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Parent class for class D,
Child class of class A
Inheritance
Class A
Class B Class C
Class D
Single
Hierarchical
Multilevel
Hybrid
 Single + Multiple inheritance
 It can only be achieved through Interface.
Parent class for class B and class C
Hybrid
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Encapsulation
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Encapsulation
Encapsulation
 Binding the data and code together as a single unit.
 Securing data by hiding the implementation details to user.
Methods Variable
Class
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Encapsulation
Output :
Getter and setter methods
ABC
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Abstraction
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Abstraction
Abstraction
 Hides the implementation details and only provides the functionality to the user
 You can achieve abstraction using Abstract classes and Interfaces
Without
Abstraction
With
Abstraction
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Abstract Class
How can you use an abstract class?
Inherit it from another class and provide implementations to the abstract methods in it.
If a class has one abstract method, then the class must be declared abstract.
1
2
abstract class <class-name> { }
 Class contains the abstract keyword
 If a class is declared abstract, it cannot be instantiated
Syntax :
Abstract class
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Interface
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Interfaces
interface Car {
void changeGear (int newValue);
void speedup (int increment);
void applyBrakes (int decrement);
}
Interfaces
 Interface in java is a blueprint of a class.
 Each method in an interface are implicitly public and abstract.
 It does not contain any constructors.
Example :
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
class Audi implements Car {
int speed = 0;
int gear = 1;
void changeGear(int newValue) {
gear = newValue;
}
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void printStates() {
System.out.println(" speed:" +
speed + " gear:" + gear);
}
}
Interfaces
To implement an interface?
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Summary
`
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Session In A Minute
Java Classes Constructors Access Modifiers
Structure of a Class Overview of Objects OOPS Concepts
Java Classes | Java Tutorial for Beginners | Java Classes and Objects | Java Training | Edureka

More Related Content

What's hot (20)

PPTX
Access modifier and inheritance
Dikshyanta Dhungana
 
PDF
Java Training | Java Tutorial for Beginners | Java Programming | Java Certifi...
Edureka!
 
PDF
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Edureka!
 
PDF
Basic Java Programming
Math-Circle
 
PPT
Abstract class in java
Lovely Professional University
 
PDF
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Edureka!
 
PPT
Java access modifiers
Srinivas Reddy
 
PPTX
This keyword in java
Hitesh Kumar
 
PDF
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Edureka!
 
PDF
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...
Edureka!
 
PPSX
Collections - Lists, Sets
Hitesh-Java
 
PPTX
ArrayList in JAVA
SAGARDAVE29
 
PPTX
Abstraction in java
sawarkar17
 
PPTX
Introduction to java
Java Lover
 
PPT
Exception Handling in JAVA
SURIT DATTA
 
PPT
Java collections concept
kumar gaurav
 
PPSX
Java &amp; advanced java
BASAVARAJ HUNSHAL
 
PPTX
WHAT IS ABSTRACTION IN JAVA
sivasundari6
 
PDF
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
PPT
20. Object-Oriented Programming Fundamental Principles
Intro C# Book
 
Access modifier and inheritance
Dikshyanta Dhungana
 
Java Training | Java Tutorial for Beginners | Java Programming | Java Certifi...
Edureka!
 
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Edureka!
 
Basic Java Programming
Math-Circle
 
Abstract class in java
Lovely Professional University
 
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Edureka!
 
Java access modifiers
Srinivas Reddy
 
This keyword in java
Hitesh Kumar
 
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Edureka!
 
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...
Edureka!
 
Collections - Lists, Sets
Hitesh-Java
 
ArrayList in JAVA
SAGARDAVE29
 
Abstraction in java
sawarkar17
 
Introduction to java
Java Lover
 
Exception Handling in JAVA
SURIT DATTA
 
Java collections concept
kumar gaurav
 
Java &amp; advanced java
BASAVARAJ HUNSHAL
 
WHAT IS ABSTRACTION IN JAVA
sivasundari6
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
20. Object-Oriented Programming Fundamental Principles
Intro C# Book
 

Similar to Java Classes | Java Tutorial for Beginners | Java Classes and Objects | Java Training | Edureka (20)

PPTX
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
mohanrajm63
 
PPTX
Android Training (Java Review)
Khaled Anaqwa
 
PPTX
Object oriented concepts
Gousalya Ramachandran
 
PDF
Core Java Programming Language (JSE) : Chapter VI - Class Design
WebStackAcademy
 
PPTX
OOP in Java Presentation.pptx
mrxyz19
 
PPTX
Core java oop
Parth Shah
 
PPTX
PPT Lecture-1.4.pptx
HimanshuPandey957216
 
PPTX
4-OOPS.pptx
SatyamMishra237306
 
PPT
Chapter 5 (OOP Principles).ppt
henokmetaferia1
 
PPTX
chapter 5 concepts of object oriented programming
WondimuBantihun1
 
PPTX
Java 102 intro to object-oriented programming in java
agorolabs
 
PPTX
Shuvrojit Majumder . 25900120006 Object Oriented Programming (PCC-CS 503) ...
ShuvrojitMajumder
 
PPTX
Object Oriented Programming ! Batra Computer Centre
jatin batra
 
PPTX
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
PPTX
Java OOPS Concept
Richa Gupta
 
PDF
JAVA-PPT'S.pdf
AnmolVerma363503
 
PPTX
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
PPTX
JAVA-PPT'S.pptx
RaazIndia
 
PPTX
Object Oriented Programming.pptx
ShuvrojitMajumder
 
PDF
Oops concepts
ACCESS Health Digital
 
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
mohanrajm63
 
Android Training (Java Review)
Khaled Anaqwa
 
Object oriented concepts
Gousalya Ramachandran
 
Core Java Programming Language (JSE) : Chapter VI - Class Design
WebStackAcademy
 
OOP in Java Presentation.pptx
mrxyz19
 
Core java oop
Parth Shah
 
PPT Lecture-1.4.pptx
HimanshuPandey957216
 
4-OOPS.pptx
SatyamMishra237306
 
Chapter 5 (OOP Principles).ppt
henokmetaferia1
 
chapter 5 concepts of object oriented programming
WondimuBantihun1
 
Java 102 intro to object-oriented programming in java
agorolabs
 
Shuvrojit Majumder . 25900120006 Object Oriented Programming (PCC-CS 503) ...
ShuvrojitMajumder
 
Object Oriented Programming ! Batra Computer Centre
jatin batra
 
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
Java OOPS Concept
Richa Gupta
 
JAVA-PPT'S.pdf
AnmolVerma363503
 
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
JAVA-PPT'S.pptx
RaazIndia
 
Object Oriented Programming.pptx
ShuvrojitMajumder
 
Oops concepts
ACCESS Health Digital
 
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
PDF
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
PDF
Tableau Tutorial for Data Science | Edureka
Edureka!
 
PDF
Python Programming Tutorial | Edureka
Edureka!
 
PDF
Top 5 PMP Certifications | Edureka
Edureka!
 
PDF
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
PDF
Linux Mint Tutorial | Edureka
Edureka!
 
PDF
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
PDF
Importance of Digital Marketing | Edureka
Edureka!
 
PDF
RPA in 2020 | Edureka
Edureka!
 
PDF
Email Notifications in Jenkins | Edureka
Edureka!
 
PDF
EA Algorithm in Machine Learning | Edureka
Edureka!
 
PDF
Cognitive AI Tutorial | Edureka
Edureka!
 
PDF
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
PDF
Blue Prism Top Interview Questions | Edureka
Edureka!
 
PDF
Big Data on AWS Tutorial | Edureka
Edureka!
 
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
PDF
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
PDF
Introduction to DevOps | Edureka
Edureka!
 
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Edureka!
 
Ad

Recently uploaded (20)

PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 

Java Classes | Java Tutorial for Beginners | Java Classes and Objects | Java Training | Edureka