SlideShare a Scribd company logo
2
Most read
5
Most read
Call : (404) 900-9988, (404) 990-3007, Mail Us: info@quontrasolutions.com
Quontra Solutions
by
Java Constructors
Constructor
• Constructor in java is a special type of method that is used to
initialize the object
• Java Constructor is invoked at the time of object creation
• They do not contain any return type
• Constructor name is same as class name
Call : (404) 900-9988, (404) 990-3007, Mail Us: info@quontrasolutions.com
Types of Constructors
• Default constructor (no-arg constructor)
• Parameterized constructor
Types of constructors
Default constructor Parameterized constructor
Call : (404) 900-9988, (404) 990-3007, Mail Us: info@quontrasolutions.com
Default Constructors
Example for default constructor:
class Cons{
cons(){
System.out.println("constructor is created");
}
public static void main(String args[]){
Cons c=new Cons();
}
}
Call : (404) 900-9988, (404) 990-3007, Mail Us: info@quontrasolutions.com
Parameterized Constructors
Example for parameterized constructor
class Student4{
int id;
String name;
Student4(int i,String n){
id = i;
name = n; }
void display(){System.out.println(id+" "+name);}
public static void main(String args[]){
Student4 s1 = new Student4(111,"Karan");
Student4 s2 = new Student4(222,"Aryan");
s1.display();
s2.display(); }
}
Call : (404) 900-9988, (404) 990-3007, Mail Us: info@quontrasolutions.com
Difference between constructor and method
Constructor 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.
Constructor name must be
same as the class name.
Method name should not
be same as class name
Call : (404) 900-9988, (404) 990-3007, Mail Us: info@quontrasolutions.com
Constructor Overloading
• Constructors are methods that can be overloaded, just like any other
method in a class.
• Constructors having the same name with different parameter list is
called constructor overloading.
Call : (404) 900-9988, (404) 990-3007, Mail Us: info@quontrasolutions.com
Topics Covered during Training
• Classes, Objects, Keywords, Methods
• Exception Handling
• String Handling
• Multithearding
• AWT
• Swing
• Applet
• Collections
• Hibernate
• Struts etc………………
Call : (404) 900-9988, (404) 990-3007, Mail Us: info@quontrasolutions.com
Quontra Solutions Offers:
Data Warehouse
OBIEE, Cognos, Informatica
Microsoft Courses
C# .NET, ASP .NET, VB .NET
& etc….
Programming Courses
Core Java, Adv Java,
J2EE, & etc….
Testing Tools
Manual, QTP, Selenium,
Load Runner
Salesforce CRM
Salesforce CRM, ADMIN,
Developer
Networking Courses
Linux, Unix, Sun Solaris,
CCNA
Mobile Apps
Android, IOS, Cloud
Computing
Data Base
SQL PL/SQL, SQL server
DBA, ORACLE 12C DBA
Other Courses…
Business Analyst, Hadoop,
Qlikview
Contact Us
Call:(404)900-9988
Mail:info@quontrasolutions.com
Visit:www.quontrasolutions.com
Call : (404) 900-9988, (404) 990-3007, Mail Us: info@quontrasolutions.com
Follow us
Facebook: https://www.facebook.com/quontrasolutionsusa
Twitter : https://twitter.com/QuontraTraining
Google+: https://plus.google.com/+Quontrasolutions/post
Call : (404) 900-9988, (404) 990-3007, Mail Us: info@quontrasolutions.com
Java constructors

More Related Content

PPTX
Dynamic method dispatch
PPTX
Java Foundations: Methods
PDF
Java Classes | Java Tutorial for Beginners | Java Classes and Objects | Java ...
PPT
Java interfaces & abstract classes
PPT
Java interfaces
PPTX
Java Methods
PDF
Java data types, variables and jvm
PDF
Java variable types
Dynamic method dispatch
Java Foundations: Methods
Java Classes | Java Tutorial for Beginners | Java Classes and Objects | Java ...
Java interfaces & abstract classes
Java interfaces
Java Methods
Java data types, variables and jvm
Java variable types

What's hot (20)

PPTX
Constructor in java
PPTX
Strings in Java
PPTX
Inheritance in java
PPSX
JDBC: java DataBase connectivity
PPTX
Interface in java
PPSX
Data Types & Variables in JAVA
PPS
Wrapper class
PPTX
Constructor in java
PDF
Class and Objects in Java
PPTX
Java program structure
PPTX
PPTX
Constructor ppt
PDF
Arrays in Java
PPTX
Polymorphism in java
PPTX
Java swing
PPT
Java collections concept
PPTX
Control statements in java
PPTX
constructors in java ppt
PPT
Generics in java
Constructor in java
Strings in Java
Inheritance in java
JDBC: java DataBase connectivity
Interface in java
Data Types & Variables in JAVA
Wrapper class
Constructor in java
Class and Objects in Java
Java program structure
Constructor ppt
Arrays in Java
Polymorphism in java
Java swing
Java collections concept
Control statements in java
constructors in java ppt
Generics in java
Ad

Viewers also liked (20)

PPTX
Constructor in java
PPTX
Constructors & destructors
PPTX
Methods and constructors in java
PPT
Java lec constructors
PDF
Constructors and Destructors
PPT
Java lec class, objects and constructors
PPTX
Class object method constructors in java
PPT
Chapter 2 Java Methods
PPT
constructor and destructor-object oriented programming
PDF
Methods in Java
DOCX
Constructor Overloading in java
PPTX
OCA JAVA - 1 Packages and Class Structure
PPTX
javaMethod.ppt
PPTX
Application of programming languages in civil engineering
PPTX
Java class 5
PPTX
Control Statements in Java
PPT
Java API, Exceptions and IO
PPTX
IMPACT OF IT IN CIVIL ENGINEERING
PPTX
Inheritance in JAVA PPT
PPT
Core java concepts
Constructor in java
Constructors & destructors
Methods and constructors in java
Java lec constructors
Constructors and Destructors
Java lec class, objects and constructors
Class object method constructors in java
Chapter 2 Java Methods
constructor and destructor-object oriented programming
Methods in Java
Constructor Overloading in java
OCA JAVA - 1 Packages and Class Structure
javaMethod.ppt
Application of programming languages in civil engineering
Java class 5
Control Statements in Java
Java API, Exceptions and IO
IMPACT OF IT IN CIVIL ENGINEERING
Inheritance in JAVA PPT
Core java concepts
Ad

Similar to Java constructors (20)

PPTX
Java Constructors with examples - Quontra Solutions
PPTX
Constructor in java
PPTX
C# Constructors
PPTX
A constructor in Java is a special method that is used to initialize objects
PPTX
Constructors
PPTX
Java constructors
PPTX
Java constructors
PPTX
constructors.pptx
PDF
Constructors in Java (2).pdf
PDF
Chapter 7 - Constructors.pdf
PPTX
Chapter 7 - Constructors.pptx
PPTX
Concept of constructors
PPTX
Java ConstructorsPPT.pptx
PPTX
Method overloading and constructor overloading in java
PPT
Constructors
PPTX
OOP's Part 1
PPTX
Lecture 5
PPTX
CONSTRUCTORS.pptx
PDF
C#. NET ONLINE TRAINING
PDF
C#.net online training
Java Constructors with examples - Quontra Solutions
Constructor in java
C# Constructors
A constructor in Java is a special method that is used to initialize objects
Constructors
Java constructors
Java constructors
constructors.pptx
Constructors in Java (2).pdf
Chapter 7 - Constructors.pdf
Chapter 7 - Constructors.pptx
Concept of constructors
Java ConstructorsPPT.pptx
Method overloading and constructor overloading in java
Constructors
OOP's Part 1
Lecture 5
CONSTRUCTORS.pptx
C#. NET ONLINE TRAINING
C#.net online training

More from QUONTRASOLUTIONS (20)

PPTX
Big data introduction by quontra solutions
PPTX
Cognos Online Training with placement Assistance - QuontraSolutions
PDF
Business analyst overview by quontra solutions
PDF
Business analyst overview by quontra solutions
PPTX
Cognos Overview
PPTX
Hibernate online training
PPTX
Java j2eeTutorial
PPTX
Software Quality Assurance training by QuontraSolutions
PPT
Introduction to software quality assurance by QuontraSolutions
PPT
.Net introduction by Quontra Solutions
PPT
Introduction to j2 ee patterns online training class
PPTX
Saas overview by quontra solutions
PPTX
Sharepoint taxonomy introduction us
PPTX
Introduction to the sharepoint 2013 userprofile service By Quontra
PPTX
Introduction to SharePoint 2013 REST API
PPTX
Performance Testing and OBIEE by QuontraSolutions
PPTX
Obiee introduction building reports by QuontraSolutions
PPTX
Sharepoint designer workflow by quontra us
PPT
Qa by quontra us
PPT
MSBI and Data WareHouse techniques by Quontra
Big data introduction by quontra solutions
Cognos Online Training with placement Assistance - QuontraSolutions
Business analyst overview by quontra solutions
Business analyst overview by quontra solutions
Cognos Overview
Hibernate online training
Java j2eeTutorial
Software Quality Assurance training by QuontraSolutions
Introduction to software quality assurance by QuontraSolutions
.Net introduction by Quontra Solutions
Introduction to j2 ee patterns online training class
Saas overview by quontra solutions
Sharepoint taxonomy introduction us
Introduction to the sharepoint 2013 userprofile service By Quontra
Introduction to SharePoint 2013 REST API
Performance Testing and OBIEE by QuontraSolutions
Obiee introduction building reports by QuontraSolutions
Sharepoint designer workflow by quontra us
Qa by quontra us
MSBI and Data WareHouse techniques by Quontra

Recently uploaded (20)

PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PDF
Pre independence Education in Inndia.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Module 3: Health Systems Tutorial Slides S2 2025
PPTX
Pharma ospi slides which help in ospi learning
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Open Quiz Monsoon Mind Game Final Set.pptx
Pre independence Education in Inndia.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Week 4 Term 3 Study Techniques revisited.pptx
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
How to Manage Starshipit in Odoo 18 - Odoo Slides
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
UPPER GASTRO INTESTINAL DISORDER.docx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Open Quiz Monsoon Mind Game Prelims.pptx
O7-L3 Supply Chain Operations - ICLT Program
Module 3: Health Systems Tutorial Slides S2 2025
Pharma ospi slides which help in ospi learning
O5-L3 Freight Transport Ops (International) V1.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student

Java constructors

  • 1. Call : (404) 900-9988, (404) 990-3007, Mail Us: [email protected] Quontra Solutions by Java Constructors
  • 2. Constructor • Constructor in java is a special type of method that is used to initialize the object • Java Constructor is invoked at the time of object creation • They do not contain any return type • Constructor name is same as class name Call : (404) 900-9988, (404) 990-3007, Mail Us: [email protected]
  • 3. Types of Constructors • Default constructor (no-arg constructor) • Parameterized constructor Types of constructors Default constructor Parameterized constructor Call : (404) 900-9988, (404) 990-3007, Mail Us: [email protected]
  • 4. Default Constructors Example for default constructor: class Cons{ cons(){ System.out.println("constructor is created"); } public static void main(String args[]){ Cons c=new Cons(); } } Call : (404) 900-9988, (404) 990-3007, Mail Us: [email protected]
  • 5. Parameterized Constructors Example for parameterized constructor class Student4{ int id; String name; Student4(int i,String n){ id = i; name = n; } void display(){System.out.println(id+" "+name);} public static void main(String args[]){ Student4 s1 = new Student4(111,"Karan"); Student4 s2 = new Student4(222,"Aryan"); s1.display(); s2.display(); } } Call : (404) 900-9988, (404) 990-3007, Mail Us: [email protected]
  • 6. Difference between constructor and method Constructor 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. Constructor name must be same as the class name. Method name should not be same as class name Call : (404) 900-9988, (404) 990-3007, Mail Us: [email protected]
  • 7. Constructor Overloading • Constructors are methods that can be overloaded, just like any other method in a class. • Constructors having the same name with different parameter list is called constructor overloading. Call : (404) 900-9988, (404) 990-3007, Mail Us: [email protected]
  • 8. Topics Covered during Training • Classes, Objects, Keywords, Methods • Exception Handling • String Handling • Multithearding • AWT • Swing • Applet • Collections • Hibernate • Struts etc……………… Call : (404) 900-9988, (404) 990-3007, Mail Us: [email protected]
  • 9. Quontra Solutions Offers: Data Warehouse OBIEE, Cognos, Informatica Microsoft Courses C# .NET, ASP .NET, VB .NET & etc…. Programming Courses Core Java, Adv Java, J2EE, & etc…. Testing Tools Manual, QTP, Selenium, Load Runner Salesforce CRM Salesforce CRM, ADMIN, Developer Networking Courses Linux, Unix, Sun Solaris, CCNA Mobile Apps Android, IOS, Cloud Computing Data Base SQL PL/SQL, SQL server DBA, ORACLE 12C DBA Other Courses… Business Analyst, Hadoop, Qlikview
  • 11. Follow us Facebook: https://www.facebook.com/quontrasolutionsusa Twitter : https://twitter.com/QuontraTraining Google+: https://plus.google.com/+Quontrasolutions/post Call : (404) 900-9988, (404) 990-3007, Mail Us: [email protected]