-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ1.java
More file actions
58 lines (43 loc) · 1.5 KB
/
Q1.java
File metadata and controls
58 lines (43 loc) · 1.5 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package CodingChalange;
class Person{
public String name;
protected int age;
private String SocialSecurityNumber; // SSN Number is only Avalible in Person Class
String address;
Person(String name,int age,String ssn, String address)
{
this.name = name;
this.age = age;
this.SocialSecurityNumber = ssn;
this.address = address;
}
void SoSeNu()
{
this.SocialSecurityNumber = "Q1w2E4";
System.out.println(SocialSecurityNumber);
}
// To Print the SSN Number Create main fuc to Person class
public static void main(String[] args) {
Person p1 = new Person("Kavin", 25, "", "kalmunai");
System.out.println(p1.name);
System.out.println(p1.age);
System.out.print(p1.SocialSecurityNumber);
System.out.println(p1.address);
}
}
class Employee extends Person{
Employee(String name,int age,String ssn, String address)
{
super(name, age, ssn, address);
System.out.println("Hello Employee");
}
}
public class Q1 {
public static void main(String[] args) {
Employee e1 = new Employee("Ahamed", 23,"W3m4i9" , "Sammanthuri");
System.out.println(e1.name);
System.out.println(e1.age);
//System.out.println(e1.SocialSecurityNumber); // This is not visible for Extends Class only visble Parent class(Person)
System.out.println(e1.address);
}
}