class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
// Person prs = new Person();
// prs.name = "john"; this will be error
// System.out.println(prs.name);
// prs.setName("John");
// System.out.println(prs.getName());
// Animal pig = new Pig();
// Animal dog = new Dog();
// pig.animalSound();
// dog.animalSound();
// OuterClass outer = new OuterClass();
// OuterClass.InnerClass inner = outer.new InnerClass();
// OuterClass.AnotherInner another = outer.new AnotherInner();
// System.out.println("Result : " + (outer.x + inner.y));
// System.out.println("Inner : " + another.myInnerMethod());
Pig pg = new Pig();
pg.animalSound();
pg.sleep();
}
}
class Person {
private String name;
public void setName (String paramName) {
this.name = paramName;
}
public String getName () {
return this.name;
}
}
class Animal {
public void animalSound() {
System.out.println("Give some noice");
}
}
class Pig extends Animal {
public void animalSound() {
System.out.println("The pig says : we we");
}
}
class Dog extends Animal {
public void animalSound() {
System.out.println("The dog says : bow bow");
}
}
class OuterClass {
int x = 10;
class InnerClass {
int y = 5;
}
class AnotherInner {
public int myInnerMethod() {
return x;
}
}
}
abstract class NewAnimal {
public abstract void animalSound();
public void sleep() {
System.out.println("zzzz");
}
}
class Pig extends NewAnimal {
public void animalSound() {
System.out.println("The pig says : yoohoo ");
}
}