Constructor Overloading in java
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
394
On Slideshare
394
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
5
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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(); } }
  • 3. OUTPUT:-