SlideShare a Scribd company logo
2
Most read
4
Most read
6
Most read
PRESENTATION
TOPIC:-
PRESENTED BY:-
CONSTRUCTORS IN JAVA
Constructors is a method having the same name of the class and
executed while while object creation . Return type is not used
while constructor declaration because constructor have class
return type by default .
Syntax:-
class – Name (para _ list)
{
//method body;
}
Based on the parameters the constructors
are categorised into two types :-
(a) Constructor without parameters
(b) Constructor with parameters
(c) Default constructor
Constructor without parameter
The constructor which are declared without parameter are known as
zero parameter constructor or constructor without parameter .
Example :-
class cTest ()
{
cTest()
{
sop(“---- cons----”);
}
}
class mains
{
psvm(string args[])
{
cTest ob=new cTest();
}
Constructor with parameter
Constructor which are declared with parameter are known as
parametrized consrtructor or constructor with parameter.
Example:-
class cTest
{
cTest( int x)
{
sop(“the value is x:”+x);
}
}
class mains
{
Psvm(stringargs[])
{
cTest ob=new cTest( 10 );
cTest
Default constructor.
They are the constructor without parameter which are added
to class at compilation stage by the compiler is known as
Default constructor .
Example :-
class cTest
{
}
class mains
{
Psvm(string args[])
{
cTest ob=new cTest();
}
}

More Related Content

PPTX
Member Function in C++
PDF
Constructors and Destructors
PPTX
Constructor and destructor
PPTX
Constructor in java
PPTX
Constructor in java
PPTX
classes and objects in C++
PDF
Operator overloading
PDF
Methods in Java
Member Function in C++
Constructors and Destructors
Constructor and destructor
Constructor in java
Constructor in java
classes and objects in C++
Operator overloading
Methods in Java

What's hot (20)

PPTX
Introduction to oop
PPTX
Inline function
PPTX
class and objects
PPT
Function overloading(c++)
PPTX
Pointers in c++
PPTX
Constructor in java
PPTX
This keyword in java
PPTX
Inheritance in java
PPT
Final keyword in java
PPTX
Applets in java
PDF
javascript objects
PPTX
Java constructors
PPTX
PPTX
Functions in c++
PPTX
Method overloading
PPTX
Inheritance in c++
PPTX
Constructor and Types of Constructors
PPTX
Java abstract class & abstract methods
PPT
Class and object in C++
Introduction to oop
Inline function
class and objects
Function overloading(c++)
Pointers in c++
Constructor in java
This keyword in java
Inheritance in java
Final keyword in java
Applets in java
javascript objects
Java constructors
Functions in c++
Method overloading
Inheritance in c++
Constructor and Types of Constructors
Java abstract class & abstract methods
Class and object in C++
Ad

Similar to constructors in java ppt (20)

PPTX
Constructors in JAva.pptx
PPTX
Java ConstructorsPPT.pptx
PPTX
CONSTRUCTORS.pptx
PDF
Constructors in Java (2).pdf
PPT
Constructors
PPTX
Constructor oopj
PPTX
Constructor in java
PDF
Java constructors and types with examples
PDF
Java Constructor
PPTX
Constructors in java
PPTX
Java Constructors
PPTX
A constructor in Java is a special method that is used to initialize objects
PPTX
Constructors in java
PPTX
object oriented programming CONSTRUCTORS.pptx
PPTX
constructors.pptx
PPTX
Constructors
PPT
Constructors.16
PDF
Chapter 7 - Constructors.pdf
PPTX
Chapter 7 - Constructors.pptx
PDF
Constructors In Java – Unveiling Object Creation
Constructors in JAva.pptx
Java ConstructorsPPT.pptx
CONSTRUCTORS.pptx
Constructors in Java (2).pdf
Constructors
Constructor oopj
Constructor in java
Java constructors and types with examples
Java Constructor
Constructors in java
Java Constructors
A constructor in Java is a special method that is used to initialize objects
Constructors in java
object oriented programming CONSTRUCTORS.pptx
constructors.pptx
Constructors
Constructors.16
Chapter 7 - Constructors.pdf
Chapter 7 - Constructors.pptx
Constructors In Java – Unveiling Object Creation
Ad

More from kunal kishore (6)

PPTX
Feasibility study ppt
PPTX
Elements of system ppt
PPTX
Operators in java presentation
PPTX
Tools of structured analysis presentation
PPTX
Probability presentation
PPTX
K-MAP(KARNAUGH MAP)BY THE SILENT PROGRAMMER
Feasibility study ppt
Elements of system ppt
Operators in java presentation
Tools of structured analysis presentation
Probability presentation
K-MAP(KARNAUGH MAP)BY THE SILENT PROGRAMMER

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
master seminar digital applications in india
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
RMMM.pdf make it easy to upload and study
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Lesson notes of climatology university.
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
01-Introduction-to-Information-Management.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Module 4: Burden of Disease Tutorial Slides S2 2025
Abdominal Access Techniques with Prof. Dr. R K Mishra
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
master seminar digital applications in india
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
VCE English Exam - Section C Student Revision Booklet
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Cell Structure & Organelles in detailed.
Chinmaya Tiranga quiz Grand Finale.pdf
A systematic review of self-coping strategies used by university students to ...
RMMM.pdf make it easy to upload and study
Final Presentation General Medicine 03-08-2024.pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Lesson notes of climatology university.
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Supply Chain Operations Speaking Notes -ICLT Program
01-Introduction-to-Information-Management.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...

constructors in java ppt

  • 2. CONSTRUCTORS IN JAVA Constructors is a method having the same name of the class and executed while while object creation . Return type is not used while constructor declaration because constructor have class return type by default . Syntax:- class – Name (para _ list) { //method body; }
  • 3. Based on the parameters the constructors are categorised into two types :- (a) Constructor without parameters (b) Constructor with parameters (c) Default constructor
  • 4. Constructor without parameter The constructor which are declared without parameter are known as zero parameter constructor or constructor without parameter . Example :- class cTest () { cTest() { sop(“---- cons----”); } } class mains { psvm(string args[]) { cTest ob=new cTest(); }
  • 5. Constructor with parameter Constructor which are declared with parameter are known as parametrized consrtructor or constructor with parameter. Example:- class cTest { cTest( int x) { sop(“the value is x:”+x); } } class mains { Psvm(stringargs[]) { cTest ob=new cTest( 10 ); cTest
  • 6. Default constructor. They are the constructor without parameter which are added to class at compilation stage by the compiler is known as Default constructor . Example :- class cTest { } class mains { Psvm(string args[]) { cTest ob=new cTest(); } }