-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoeduhub.java
More file actions
41 lines (33 loc) · 881 Bytes
/
Goeduhub.java
File metadata and controls
41 lines (33 loc) · 881 Bytes
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
34
35
36
37
38
39
40
41
package com.company;
public class Goeduhub {
int id;
String name;
// Default constructor
Goeduhub(){
System.out.println("Default constructor called!");
}
// Parameterized constructor
Goeduhub(int i, String n){
id = i;
name = n;
System.out.println("Parameterized constructor called!");
}
// Copy constructor
Goeduhub(Goeduhub g){
id = g.id;
name = g.name;
System.out.println("Copy constructor called!");
}
// Method to display values
void display(){
System.out.println("ID: " + id + ", Name: " + name);
}
public static void main(String[] args){
Goeduhub g1 = new Goeduhub();
g1.display();
Goeduhub g2 = new Goeduhub(101, "Goeduhub");
g2.display();
Goeduhub g3 = new Goeduhub(g2);
g3.display();
}
}