Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AA
- {
- int i=10;
- void method()
- {
- System.out.println("AA "+i);
- }
- }
- class BB extends AA
- {
- int i = 20;
- void method()
- {
- AA a = new BB();
- System.out.println("BB "+a.i);
- }
- }
- public class MainClass
- {
- public static void main(String[] args)
- {
- AA a = new BB();
- BB b = new BB();
- a.method();
- b.method();
- System.out.println(a.i);
- System.out.println(b.i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement