-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerConstructor.java
More file actions
33 lines (31 loc) · 1.08 KB
/
Copy pathCustomerConstructor.java
File metadata and controls
33 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package java_core;
public class CustomerConstructor {
String customerID;
String customerName;
String contactNo;
String address;
CustomerConstructor(){
System.out.println("this is a parameterless constructor");
}
CustomerConstructor(String cid, String cname, String phno, String add){
System.out.println("Parameterized constructor called");
customerID = cid;
customerName = cname;
contactNo = phno;
address = add;
}
void displayDetails(){
System.out.println("Your Customer ID is: "+customerID);
System.out.println("Your name is: "+customerName);
System.out.println("Your phone number is: "+contactNo);
System.out.println("Your address is: "+address);
}
}
class tester{
public static void main(String args[]){
CustomerConstructor customer1 = new CustomerConstructor();
CustomerConstructor customer2 = new CustomerConstructor("C001", "Gaurav", "9270239980", "surya bakery, Mysore");
customer1.displayDetails();
customer2.displayDetails();
}
}