SlideShare a Scribd company logo
Classes
&
Objects
In JAVA
-M Vishnuvardhan,
Dept. of Computer Science,
SSBN Degree College, ATP
SSBN Degree College, ATP M Vishnuvardhan
Introduction
In real world we can find many objects like car, student, … All these
objects have state and behavior. To represent these real world entitles
Objects are used in software. Object is software representation of real
life thing. In order to create an object first wee need to describe how
the object should be.
SSBN Degree College, ATP M Vishnuvardhan
Class
A class is a template which describes an Entity or Object.
i.e., A class is a blueprint of the object. Using a class it is possible to
create multiple objects
A class describes an entity in two ways
1.Properties of class (gives characteristics)
2.Behavior(functionality)
Eg: Student --- RollNo, Name, gender ….
--- getAdmission, writeExam, getResult
SSBN Degree College, ATP M Vishnuvardhan
Representation of Class
Syntax:
class ClassName
{
declaration of properties
definations of methods
}
class Student
{
int rollNo;
String name;
void getAdmission()
{ ================ }
}
SSBN Degree College, ATP M Vishnuvardhan
Class - Properties
These are special variables used to describe the characteristics of an
Object. These are also called as attributes/ data members / data.
Syntax :
<<access Specifier>> dataType PropertyName;
Eg:
int rollNo;
String name;
Access Specifier controls the availability and accessibility of member
of a class in different parts of the program.
Eg:- public, private, protected, private protected & default.
For Every member access Specifier need to specified separately
SSBN Degree College, ATP M Vishnuvardhan
Class - Methods
These are functions used to describe the behavior of an Object.
These are also called as member functions/ code.
Syntax :
<<access Specifier>> returnType methodName(<<arguments>>)
{
======= // body of the method (method definition)
}
Eg: void getAdmisssion()
{
=====
}
void printData(int x)
{
=====
}
SSBN Degree College, ATP M Vishnuvardhan
Class - Methods
class Box
{
int length, width;
double area, perimeter;
void calculate()
{
area=length*width;
perimeter=2*(length+width);
}
void printData()
{
System.out.println(“Length:”+length);
System.out.println(“Width:”+width);
System.out.println(“Area:”+area);
System.out.println(“Perimeter:”+perimeter);
}
}
SSBN Degree College, ATP M Vishnuvardhan
Properties of Constructors
» A constructor cannot be called like a ordinary method.
» A constructor is called only once in the life time of an object.
» A constructor is always invoked at the time of creation of object
with the help of new keyword.
» Every class must have a constructor. Without constructor object
creation is not possible.
» If a constructor is not defined for a class the compiler provides a
constructor for the class.
SSBN Degree College, ATP M Vishnuvardhan
Constructor vs. method
Java Constructor Java Method
Constructor is used to initialize the
state of an object.
Method is used to expose
behaviour of an object.
Constructor must not have return
type.
Method must have return type.
Constructor is invoked implicitly. Method is invoked explicitly.
The java compiler provides a default
constructor if you don't have any
constructor.
Method is not provided by
compiler in any case.
Constructor name must be same as
the class name.
Method name may or may not
be same as class name.
SSBN Degree College, ATP M Vishnuvardhan
Types of Constructors
Constructors in java can be of two types
»Default Constructor:
Constructor provided by the compiler is called as default
constructor or a constructor with out parameters is also called as
default constructor
»Parameterized Constructor:
Constructor with parameters is called as parameterized
constructors.
SSBN Degree College, ATP M Vishnuvardhan
Types of Constructors
Constructors in java can be of two types
»Default Constructor:
Constructor provided by the compiler is called as default
constructor or a constructor with out parameters is also called as
default constructor
»Parameterized Constructor:
Constructor with parameters is called as parameterized
constructors.
SSBN Degree College, ATP M Vishnuvardhan
Questions

More Related Content

What's hot

Threads in JAVA
Threads in JAVAThreads in JAVA
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
tanu_jaswal
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
Math-Circle
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
CPD INDIA
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
Abir Mohammad
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Java IO
Java IOJava IO
Java IO
UTSAB NEUPANE
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
Hitesh Kumar
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
Farooq Baloch
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
Arati Gadgil
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
Ahmed Farag
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Naz Abdalla
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streamsShahjahan Samoon
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
CodeOps Technologies LLP
 
Generics in java
Generics in javaGenerics in java
Generics in java
suraj pandey
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 
Wrapper class
Wrapper classWrapper class
Wrapper class
kamal kotecha
 

What's hot (20)

Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Java IO
Java IOJava IO
Java IO
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
 
Generics in java
Generics in javaGenerics in java
Generics in java
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Java packages
Java packagesJava packages
Java packages
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 

Similar to Classes&amp;objects

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
 
Constructors
ConstructorsConstructors
Constructors
M Vishnuvardhan Reddy
 
constructors.pptx
constructors.pptxconstructors.pptx
constructors.pptx
Epsiba1
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
madhavi patil
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
BG Java EE Course
 
Oop scala
Oop scalaOop scala
Oop scalaAnsviaLab
 
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects newlykado0dles
 
Sonu wiziq
Sonu wiziqSonu wiziq
Sonu wiziq
Sonu WIZIQ
 
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes
Uzair Salman
 
oopusingc.pptx
oopusingc.pptxoopusingc.pptx
oopusingc.pptx
MohammedAlobaidy16
 
how to create object
how to create objecthow to create object
how to create object
Subhasis Nayak
 
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
argsstring
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
Avinash Kapse
 
classandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptclassandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.ppt
manomkpsg
 
UNIT - IIInew.pptx
UNIT - IIInew.pptxUNIT - IIInew.pptx
UNIT - IIInew.pptx
akila m
 
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCECLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
Venugopalavarma Raja
 
Lecture01 object oriented-programming
Lecture01 object oriented-programmingLecture01 object oriented-programming
Lecture01 object oriented-programmingHariz Mustafa
 
Classes-and-Object.pptx
Classes-and-Object.pptxClasses-and-Object.pptx
Classes-and-Object.pptx
VishwanathanS5
 
Unit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptxUnit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptx
DrYogeshDeshmukh1
 
C++Constructors
C++ConstructorsC++Constructors
C++Constructors
Nusrat Gulbarga
 

Similar to Classes&amp;objects (20)

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
 
Constructors
ConstructorsConstructors
Constructors
 
constructors.pptx
constructors.pptxconstructors.pptx
constructors.pptx
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
 
Oop scala
Oop scalaOop scala
Oop scala
 
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects new
 
Sonu wiziq
Sonu wiziqSonu wiziq
Sonu wiziq
 
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes
 
oopusingc.pptx
oopusingc.pptxoopusingc.pptx
oopusingc.pptx
 
how to create object
how to create objecthow to create object
how to create object
 
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
classandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptclassandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.ppt
 
UNIT - IIInew.pptx
UNIT - IIInew.pptxUNIT - IIInew.pptx
UNIT - IIInew.pptx
 
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCECLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
 
Lecture01 object oriented-programming
Lecture01 object oriented-programmingLecture01 object oriented-programming
Lecture01 object oriented-programming
 
Classes-and-Object.pptx
Classes-and-Object.pptxClasses-and-Object.pptx
Classes-and-Object.pptx
 
Unit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptxUnit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptx
 
C++Constructors
C++ConstructorsC++Constructors
C++Constructors
 

More from M Vishnuvardhan Reddy

Python Sets_Dictionary.pptx
Python Sets_Dictionary.pptxPython Sets_Dictionary.pptx
Python Sets_Dictionary.pptx
M Vishnuvardhan Reddy
 
Lists_tuples.pptx
Lists_tuples.pptxLists_tuples.pptx
Lists_tuples.pptx
M Vishnuvardhan Reddy
 
Python Control Structures.pptx
Python Control Structures.pptxPython Control Structures.pptx
Python Control Structures.pptx
M Vishnuvardhan Reddy
 
Python Strings.pptx
Python Strings.pptxPython Strings.pptx
Python Strings.pptx
M Vishnuvardhan Reddy
 
Python Basics.pptx
Python Basics.pptxPython Basics.pptx
Python Basics.pptx
M Vishnuvardhan Reddy
 
Python Operators.pptx
Python Operators.pptxPython Operators.pptx
Python Operators.pptx
M Vishnuvardhan Reddy
 
Python Datatypes.pptx
Python Datatypes.pptxPython Datatypes.pptx
Python Datatypes.pptx
M Vishnuvardhan Reddy
 
DataScience.pptx
DataScience.pptxDataScience.pptx
DataScience.pptx
M Vishnuvardhan Reddy
 
Html forms
Html formsHtml forms
Html forms
M Vishnuvardhan Reddy
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
M Vishnuvardhan Reddy
 
Java Threads
Java ThreadsJava Threads
Java Threads
M Vishnuvardhan Reddy
 
Java Streams
Java StreamsJava Streams
Java Streams
M Vishnuvardhan Reddy
 
Scanner class
Scanner classScanner class
Scanner class
M Vishnuvardhan Reddy
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
M Vishnuvardhan Reddy
 
Java intro
Java introJava intro
Java intro
M Vishnuvardhan Reddy
 
Java applets
Java appletsJava applets
Java applets
M Vishnuvardhan Reddy
 
Exception handling
Exception handling Exception handling
Exception handling
M Vishnuvardhan Reddy
 
Control structures
Control structuresControl structures
Control structures
M Vishnuvardhan Reddy
 
Shell sort
Shell sortShell sort
Shell sort
M Vishnuvardhan Reddy
 
Selection sort
Selection sortSelection sort
Selection sort
M Vishnuvardhan Reddy
 

More from M Vishnuvardhan Reddy (20)

Python Sets_Dictionary.pptx
Python Sets_Dictionary.pptxPython Sets_Dictionary.pptx
Python Sets_Dictionary.pptx
 
Lists_tuples.pptx
Lists_tuples.pptxLists_tuples.pptx
Lists_tuples.pptx
 
Python Control Structures.pptx
Python Control Structures.pptxPython Control Structures.pptx
Python Control Structures.pptx
 
Python Strings.pptx
Python Strings.pptxPython Strings.pptx
Python Strings.pptx
 
Python Basics.pptx
Python Basics.pptxPython Basics.pptx
Python Basics.pptx
 
Python Operators.pptx
Python Operators.pptxPython Operators.pptx
Python Operators.pptx
 
Python Datatypes.pptx
Python Datatypes.pptxPython Datatypes.pptx
Python Datatypes.pptx
 
DataScience.pptx
DataScience.pptxDataScience.pptx
DataScience.pptx
 
Html forms
Html formsHtml forms
Html forms
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Java Threads
Java ThreadsJava Threads
Java Threads
 
Java Streams
Java StreamsJava Streams
Java Streams
 
Scanner class
Scanner classScanner class
Scanner class
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Java intro
Java introJava intro
Java intro
 
Java applets
Java appletsJava applets
Java applets
 
Exception handling
Exception handling Exception handling
Exception handling
 
Control structures
Control structuresControl structures
Control structures
 
Shell sort
Shell sortShell sort
Shell sort
 
Selection sort
Selection sortSelection sort
Selection sort
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 

Classes&amp;objects

  • 1. Classes & Objects In JAVA -M Vishnuvardhan, Dept. of Computer Science, SSBN Degree College, ATP
  • 2. SSBN Degree College, ATP M Vishnuvardhan Introduction In real world we can find many objects like car, student, … All these objects have state and behavior. To represent these real world entitles Objects are used in software. Object is software representation of real life thing. In order to create an object first wee need to describe how the object should be.
  • 3. SSBN Degree College, ATP M Vishnuvardhan Class A class is a template which describes an Entity or Object. i.e., A class is a blueprint of the object. Using a class it is possible to create multiple objects A class describes an entity in two ways 1.Properties of class (gives characteristics) 2.Behavior(functionality) Eg: Student --- RollNo, Name, gender …. --- getAdmission, writeExam, getResult
  • 4. SSBN Degree College, ATP M Vishnuvardhan Representation of Class Syntax: class ClassName { declaration of properties definations of methods } class Student { int rollNo; String name; void getAdmission() { ================ } }
  • 5. SSBN Degree College, ATP M Vishnuvardhan Class - Properties These are special variables used to describe the characteristics of an Object. These are also called as attributes/ data members / data. Syntax : <<access Specifier>> dataType PropertyName; Eg: int rollNo; String name; Access Specifier controls the availability and accessibility of member of a class in different parts of the program. Eg:- public, private, protected, private protected & default. For Every member access Specifier need to specified separately
  • 6. SSBN Degree College, ATP M Vishnuvardhan Class - Methods These are functions used to describe the behavior of an Object. These are also called as member functions/ code. Syntax : <<access Specifier>> returnType methodName(<<arguments>>) { ======= // body of the method (method definition) } Eg: void getAdmisssion() { ===== } void printData(int x) { ===== }
  • 7. SSBN Degree College, ATP M Vishnuvardhan Class - Methods class Box { int length, width; double area, perimeter; void calculate() { area=length*width; perimeter=2*(length+width); } void printData() { System.out.println(“Length:”+length); System.out.println(“Width:”+width); System.out.println(“Area:”+area); System.out.println(“Perimeter:”+perimeter); } }
  • 8. SSBN Degree College, ATP M Vishnuvardhan Properties of Constructors » A constructor cannot be called like a ordinary method. » A constructor is called only once in the life time of an object. » A constructor is always invoked at the time of creation of object with the help of new keyword. » Every class must have a constructor. Without constructor object creation is not possible. » If a constructor is not defined for a class the compiler provides a constructor for the class.
  • 9. SSBN Degree College, ATP M Vishnuvardhan Constructor vs. method Java Constructor Java Method Constructor is used to initialize the state of an object. Method is used to expose behaviour of an object. Constructor must not have return type. Method must have return type. Constructor is invoked implicitly. Method is invoked explicitly. The java compiler provides a default constructor if you don't have any constructor. Method is not provided by compiler in any case. Constructor name must be same as the class name. Method name may or may not be same as class name.
  • 10. SSBN Degree College, ATP M Vishnuvardhan Types of Constructors Constructors in java can be of two types »Default Constructor: Constructor provided by the compiler is called as default constructor or a constructor with out parameters is also called as default constructor »Parameterized Constructor: Constructor with parameters is called as parameterized constructors.
  • 11. SSBN Degree College, ATP M Vishnuvardhan Types of Constructors Constructors in java can be of two types »Default Constructor: Constructor provided by the compiler is called as default constructor or a constructor with out parameters is also called as default constructor »Parameterized Constructor: Constructor with parameters is called as parameterized constructors.
  • 12. SSBN Degree College, ATP M Vishnuvardhan Questions