Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Constructors
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package oopsConcepts;

class Constructor {
int id;
String name;
double salary;
public Constructor(int id, String name, double salary) {
this. id = id;
this.name = name;
this.salary = salary;
}


Constructor(int id, String name) { // Constructor Overloading
this.id = id;
this.name = name; }

Constructor(int id) {
this.id = id;
}

public void display() {
System.out.println(id+" "+name+" "+salary);

}
public static void main(String[] args) {
Constructor t1 = new Constructor(1,"Alekha",1000.00);
Constructor t2 = new Constructor(1,"jaijai");
Constructor t3 = new Constructor(1);

//t1.id = 100;
t3.display();

t1.display();
t2.display();
}

}