add EncapsulationInheritancePolymorphism

This commit is contained in:
Oleksii Aleshchenko
2023-02-16 16:10:38 +02:00
parent f4fbabe6e5
commit 81947f9b29
6 changed files with 171 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
public class Main {
public static void main(String[] args) {
System.out.println(args[1]);
System.out.println("Hello world!");
// System.out.println(1);
}

View File

@@ -0,0 +1,20 @@
package encapsulationInheritancePolymorphism;
public class Encapsulation {
/*private*/ int field;
private int field2;
// int a = 1;
public void myMethodForTheField () {
System.out.println(field);
}
public void myMethodForTheField2 () {
System.out.println(field);
}
public void myMethodForTheFieldAndTheField2 () {
System.out.println(field);
}
}

View File

@@ -0,0 +1,10 @@
package encapsulationInheritancePolymorphism;
public class EncapsulationInheritancePolymorphism {
public static void main(String[] args) {
int a = 1;
// var b = 2;
// System.out.println(b);
}
}

View File

@@ -0,0 +1,10 @@
package encapsulationInheritancePolymorphism;
public class Student {
private String name;
private String surname;
public String getName() {
return name;
}
}