+ 1
Why do i need two classes here:
public class Animal { void bark() { System.out.println("Woof-Woof"); } } class MyClass { public static void main(String[ ] args) { Animal dog = new Animal(); dog.bark(); } }
2 Answers
+ 1
you don't need 2 classes for that, You can create main method in Animal class only with Animal object.
But 2 classes is best way to understand OOP'S
0
You are using myClass to test Animal class everything looks good