SlideShare ist ein Scribd-Unternehmen logo
1 von 3
//Ques. 9 WAP on constructor overloading.

class Student
{
privateintrollNumber;
private String name;
public Student()
{
System.out.println("n Inside Default Constructor");
rollNumber=0;
name="Unknown";
}
public Student(introllNumber,String name)
{
System.out.println("n Inside Overloaded Constructor");
this.rollNumber = rollNumber;
this.name=name;
}
public void displayStudent()
{
System.out.println(" Name = "+name);
System.out.println(" Roll No. = "+rollNumber);
}
}
classConstructorOverLoad
{
public static void main(String arg[])
{
Student s1 = new Student(7448264,"Ultimate Virus");
s1.displayStudent();
Student s2 = new Student();
s2.displayStudent();
}
}
OUTPUT:-

Weitere ähnliche Inhalte

Was ist angesagt?

Cardiac output monitoring
Cardiac output monitoringCardiac output monitoring
Cardiac output monitoring
NIICS
 
Circle system low flow anesthesia
Circle system low flow anesthesiaCircle system low flow anesthesia
Circle system low flow anesthesia
Drgeeta Choudhary
 
Preoperative Assessment (Intro)
Preoperative Assessment (Intro)Preoperative Assessment (Intro)
Preoperative Assessment (Intro)
Andrew Ferguson
 
Anaesthesia for spine surgery
Anaesthesia for spine surgeryAnaesthesia for spine surgery
Anaesthesia for spine surgery
Asi-oqua Bassey
 
Central nervous system physiology and cerebral blood flow2012
Central nervous system physiology and cerebral blood flow2012Central nervous system physiology and cerebral blood flow2012
Central nervous system physiology and cerebral blood flow2012
Siti Azila
 

Was ist angesagt? (20)

Monitoring depth of anesthesia
Monitoring depth of anesthesiaMonitoring depth of anesthesia
Monitoring depth of anesthesia
 
Ambulatory anesthesia copy
Ambulatory anesthesia   copyAmbulatory anesthesia   copy
Ambulatory anesthesia copy
 
Cardiac output monitoring
Cardiac output monitoringCardiac output monitoring
Cardiac output monitoring
 
IV induction agents
IV induction agentsIV induction agents
IV induction agents
 
Checking of anaesthesia machine
Checking of anaesthesia machineChecking of anaesthesia machine
Checking of anaesthesia machine
 
Awake Craniotomy Anaesthesia.pptx
Awake Craniotomy Anaesthesia.pptxAwake Craniotomy Anaesthesia.pptx
Awake Craniotomy Anaesthesia.pptx
 
Circle system low flow anesthesia
Circle system low flow anesthesiaCircle system low flow anesthesia
Circle system low flow anesthesia
 
Local anesthetics and additives
Local anesthetics and additives Local anesthetics and additives
Local anesthetics and additives
 
Anaesthesia in robotic surgery
Anaesthesia in robotic surgeryAnaesthesia in robotic surgery
Anaesthesia in robotic surgery
 
Anesthesia Ventilator
Anesthesia VentilatorAnesthesia Ventilator
Anesthesia Ventilator
 
Positioning in anaesthesia mgmc
Positioning in anaesthesia mgmcPositioning in anaesthesia mgmc
Positioning in anaesthesia mgmc
 
Sedation and analgesia in icu
Sedation and analgesia in icuSedation and analgesia in icu
Sedation and analgesia in icu
 
Breathing systems
Breathing systemsBreathing systems
Breathing systems
 
epidural anaesthesia.pptx
epidural anaesthesia.pptxepidural anaesthesia.pptx
epidural anaesthesia.pptx
 
Preoperative Assessment (Intro)
Preoperative Assessment (Intro)Preoperative Assessment (Intro)
Preoperative Assessment (Intro)
 
Anaesthesia for spine surgery
Anaesthesia for spine surgeryAnaesthesia for spine surgery
Anaesthesia for spine surgery
 
Monitoring depth of anaesthesia
Monitoring depth of anaesthesiaMonitoring depth of anaesthesia
Monitoring depth of anaesthesia
 
Central nervous system physiology and cerebral blood flow2012
Central nervous system physiology and cerebral blood flow2012Central nervous system physiology and cerebral blood flow2012
Central nervous system physiology and cerebral blood flow2012
 
Anaesthesia for robotic surgery
Anaesthesia for robotic surgeryAnaesthesia for robotic surgery
Anaesthesia for robotic surgery
 
Concerns and challenges during anesthetic management of aneurysmal
Concerns and challenges during anesthetic management of   aneurysmalConcerns and challenges during anesthetic management of   aneurysmal
Concerns and challenges during anesthetic management of aneurysmal
 

Andere mochten auch

IMPACT OF IT IN CIVIL ENGINEERING
IMPACT OF IT IN CIVIL ENGINEERINGIMPACT OF IT IN CIVIL ENGINEERING
IMPACT OF IT IN CIVIL ENGINEERING
Kulbir Singh gill
 

Andere mochten auch (16)

Overloading
Overloading Overloading
Overloading
 
program on Function overloading in java
program on  Function overloading in javaprogram on  Function overloading in java
program on Function overloading in java
 
Methods and constructors in java
Methods and constructors in javaMethods and constructors in java
Methods and constructors in java
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Application of programming languages in civil engineering
Application of programming languages in civil engineeringApplication of programming languages in civil engineering
Application of programming languages in civil engineering
 
Constructor overloading in C++
Constructor overloading in C++Constructor overloading in C++
Constructor overloading in C++
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Java Programming - Introduction to Abstract Class
Java Programming - Introduction to Abstract ClassJava Programming - Introduction to Abstract Class
Java Programming - Introduction to Abstract Class
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
IMPACT OF IT IN CIVIL ENGINEERING
IMPACT OF IT IN CIVIL ENGINEERINGIMPACT OF IT IN CIVIL ENGINEERING
IMPACT OF IT IN CIVIL ENGINEERING
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Class object method constructors in java
Class object method constructors in javaClass object method constructors in java
Class object method constructors in java
 
Method overloading and constructor overloading in java
Method overloading and constructor overloading in javaMethod overloading and constructor overloading in java
Method overloading and constructor overloading in java
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 

Mehr von One97 Communications Limited

Mehr von One97 Communications Limited (20)

Er. Model Of Hospital Management
Er. Model Of Hospital ManagementEr. Model Of Hospital Management
Er. Model Of Hospital Management
 
Financial
FinancialFinancial
Financial
 
Railway
RailwayRailway
Railway
 
Library
LibraryLibrary
Library
 
Fcfs Cpu Scheduling With Gantt Chart
Fcfs Cpu Scheduling With Gantt ChartFcfs Cpu Scheduling With Gantt Chart
Fcfs Cpu Scheduling With Gantt Chart
 
Neural Interfacing
Neural Interfacing Neural Interfacing
Neural Interfacing
 
Blue eye technology
Blue eye technology Blue eye technology
Blue eye technology
 
Computer Forensics
Computer ForensicsComputer Forensics
Computer Forensics
 
Backtrack
BacktrackBacktrack
Backtrack
 
Protect Folders without using any Software
Protect Folders without using any SoftwareProtect Folders without using any Software
Protect Folders without using any Software
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Topology
TopologyTopology
Topology
 
WAP to invoke constructors using super keyword in java
WAP to invoke constructors using super keyword in javaWAP to invoke constructors using super keyword in java
WAP to invoke constructors using super keyword in java
 
WAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in javaWAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in java
 
Overriding abstract in java
Overriding abstract in javaOverriding abstract in java
Overriding abstract in java
 
How to achieve multiple inheritances by using interface in java
How to achieve multiple inheritances by using interface in java How to achieve multiple inheritances by using interface in java
How to achieve multiple inheritances by using interface in java
 
Method overriding in java
Method overriding in javaMethod overriding in java
Method overriding in java
 
WAP to implement inheritance and overloading methods in java
WAP to implement inheritance and overloading methods in javaWAP to implement inheritance and overloading methods in java
WAP to implement inheritance and overloading methods in java
 
Program on usage of Final keyword in java
Program on usage of  Final keyword in javaProgram on usage of  Final keyword in java
Program on usage of Final keyword in java
 
WAP to initialize different objects with different values in java
WAP to initialize different objects with different values in javaWAP to initialize different objects with different values in java
WAP to initialize different objects with different values in java
 

Kürzlich hochgeladen

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Kürzlich hochgeladen (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 

Constructor Overloading in java

  • 1. //Ques. 9 WAP on constructor overloading. class Student { privateintrollNumber; private String name; public Student() { System.out.println("n Inside Default Constructor"); rollNumber=0; name="Unknown"; } public Student(introllNumber,String name) { System.out.println("n Inside Overloaded Constructor"); this.rollNumber = rollNumber; this.name=name; } public void displayStudent() { System.out.println(" Name = "+name); System.out.println(" Roll No. = "+rollNumber);
  • 2. } } classConstructorOverLoad { public static void main(String arg[]) { Student s1 = new Student(7448264,"Ultimate Virus"); s1.displayStudent(); Student s2 = new Student(); s2.displayStudent(); } }