-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChapter_12_PS.java
More file actions
33 lines (26 loc) · 1001 Bytes
/
Chapter_12_PS.java
File metadata and controls
33 lines (26 loc) · 1001 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
// package folder.folder1.folder2;// This is for question-3
// package calc; // This is for question-2
class Calculator {
public void add(int num1, int num2) {
System.out.printf("%d + %d = %d\n", num1, num1, (num1 + num2));
}
protected String num1 = "Hello i am protected in subclass";
String num2 = "Hello i am a default";
}
class scCalculator {
public void calculate(int num1, int num2) {
System.out.printf("%d + %d = %d\n", num1, num1, (num1 + num2));
}
}
class hyCalculator {
public void calculateAnother(int num1, int num2) {
System.out.printf("%d + %d = %d\n", num1, num1, (num1 + num2));
}
}
public class Chapter_12_PS {
public static void main(String[] args) {
System.out.println("I am an main method!");
}
protected String num1 = "Hello i am protected in subclass"; // This will be protected will be accessed
String num2 = "Hello i am a default"; // This is a default we cannot access from the subclass
}