extras: add P16-P23, P25
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
24
P23.java
Normal file
24
P23.java
Normal file
@@ -0,0 +1,24 @@
|
||||
public class P23 {
|
||||
private String parentVariable = "Parent";
|
||||
|
||||
public void parentMethod() {
|
||||
System.out.println("Parent method");
|
||||
Child child = new Child();
|
||||
child.childMethod();
|
||||
}
|
||||
|
||||
public class Child {
|
||||
private String childVariable = "Child";
|
||||
|
||||
public void childMethod() {
|
||||
System.out.println("Child method");
|
||||
System.out.println("Accessing parent variable: " + parentVariable);
|
||||
System.out.println("Accessing child variable: " + childVariable);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
P23 parent = new P23();
|
||||
parent.parentMethod();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user