`
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

PDF
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
PPT
Oops in Java
PDF
Java Training | Java Tutorial for Beginners | Java Programming | Java Certifi...
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
PPTX
Access modifiers in java
PPTX
Getters_And_Setters.pptx
PPTX
Core java
PPTX
Object Oriented Programing JAVA presentaion
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Oops in Java
Java Training | Java Tutorial for Beginners | Java Programming | Java Certifi...
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Access modifiers in java
Getters_And_Setters.pptx
Core java
Object Oriented Programing JAVA presentaion

What's hot (20)

PPTX
Spring Boot
PDF
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
PDF
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
PDF
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
PDF
Spring Boot
PPT
jpa-hibernate-presentation
PDF
Basic Java Programming
PDF
Spring Framework - Core
PPSX
Introduction to java
PPT
Spring Boot in Action
PDF
PUC SE Day 2019 - SpringBoot
PPTX
Spring Boot Tutorial
PPT
Introduction to Java Programming, Basic Structure, variables Data type, input...
PPTX
Core Java Tutorials by Mahika Tutorials
PDF
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
PPTX
Spring boot
PPTX
Spring boot
PPT
Spring mvc
PPTX
Spring boot - an introduction
PPTX
Introduction to Spring Framework
Spring Boot
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Spring Boot
jpa-hibernate-presentation
Basic Java Programming
Spring Framework - Core
Introduction to java
Spring Boot in Action
PUC SE Day 2019 - SpringBoot
Spring Boot Tutorial
Introduction to Java Programming, Basic Structure, variables Data type, input...
Core Java Tutorials by Mahika Tutorials
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
Spring boot
Spring boot
Spring mvc
Spring boot - an introduction
Introduction to Spring Framework
Ad

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

PPTX
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
PPTX
Android Training (Java Review)
PPTX
Object oriented concepts
PDF
Core Java Programming Language (JSE) : Chapter VI - Class Design
PPTX
OOP in Java Presentation.pptx
PPTX
Core java oop
PPTX
PPT Lecture-1.4.pptx
PPTX
4-OOPS.pptx
PPT
Chapter 5 (OOP Principles).ppt
PPTX
chapter 5 concepts of object oriented programming
PPTX
Java 102 intro to object-oriented programming in java
PPTX
Shuvrojit Majumder . 25900120006 Object Oriented Programming (PCC-CS 503) ...
PPTX
Object Oriented Programming ! Batra Computer Centre
PPTX
Object Oriented Programming Tutorial.pptx
PPTX
Java OOPS Concept
PDF
JAVA-PPT'S.pdf
PPTX
JAVA-PPT'S-complete-chrome.pptx
PPTX
JAVA-PPT'S.pptx
PPTX
Object Oriented Programming.pptx
PDF
Oops concepts
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
Android Training (Java Review)
Object oriented concepts
Core Java Programming Language (JSE) : Chapter VI - Class Design
OOP in Java Presentation.pptx
Core java oop
PPT Lecture-1.4.pptx
4-OOPS.pptx
Chapter 5 (OOP Principles).ppt
chapter 5 concepts of object oriented programming
Java 102 intro to object-oriented programming in java
Shuvrojit Majumder . 25900120006 Object Oriented Programming (PCC-CS 503) ...
Object Oriented Programming ! Batra Computer Centre
Object Oriented Programming Tutorial.pptx
Java OOPS Concept
JAVA-PPT'S.pdf
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S.pptx
Object Oriented Programming.pptx
Oops concepts
Ad

More from Edureka! (20)

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

Recently uploaded (20)

PDF
TicketRoot: Event Tech Solutions Deck 2025
PDF
NewMind AI Journal Monthly Chronicles - August 2025
PDF
ELLIE29.pdfWETWETAWTAWETAETAETERTRTERTER
PDF
Introduction to c language from lecture slides
PDF
Decision Optimization - From Theory to Practice
PPTX
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
PDF
Domain-specific knowledge and context in large language models: challenges, c...
PDF
Optimizing bioinformatics applications: a novel approach with human protein d...
PDF
substrate PowerPoint Presentation basic one
PDF
The Digital Engine Room: Unlocking APAC’s Economic and Digital Potential thro...
PDF
Advancements in abstractive text summarization: a deep learning approach
PDF
Human Computer Interaction Miterm Lesson
PDF
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
PPTX
CRM(Customer Relationship Managmnet) Presentation
PDF
【AI論文解説】高速・高品質な生成を実現するFlow Map Models(Part 1~3)
PDF
Uncertainty-aware contextual multi-armed bandits for recommendations in e-com...
PDF
Ebook - The Future of AI A Comprehensive Guide.pdf
PDF
Addressing the challenges of harmonizing law and artificial intelligence tech...
PDF
Technical Debt in the AI Coding Era - By Antonio Bianco
PDF
Altius execution marketplace concept.pdf
TicketRoot: Event Tech Solutions Deck 2025
NewMind AI Journal Monthly Chronicles - August 2025
ELLIE29.pdfWETWETAWTAWETAETAETERTRTERTER
Introduction to c language from lecture slides
Decision Optimization - From Theory to Practice
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
Domain-specific knowledge and context in large language models: challenges, c...
Optimizing bioinformatics applications: a novel approach with human protein d...
substrate PowerPoint Presentation basic one
The Digital Engine Room: Unlocking APAC’s Economic and Digital Potential thro...
Advancements in abstractive text summarization: a deep learning approach
Human Computer Interaction Miterm Lesson
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
CRM(Customer Relationship Managmnet) Presentation
【AI論文解説】高速・高品質な生成を実現するFlow Map Models(Part 1~3)
Uncertainty-aware contextual multi-armed bandits for recommendations in e-com...
Ebook - The Future of AI A Comprehensive Guide.pdf
Addressing the challenges of harmonizing law and artificial intelligence tech...
Technical Debt in the AI Coding Era - By Antonio Bianco
Altius execution marketplace concept.pdf

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