Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

I got my finals coming up tomorrow and....

Sat Dec 27, 2008 12:05 pm

see, i admit it, i suck at it. but im in a second time porbation now and i gotta do something. but i cant do it alone. thats where you guys (whoevers gonna help me) comes in play. ok, heres the question.
suppose, theres three class, blue, moo and crew.

Code:
class Blue {
  void method1() {
    System.out.println("blue 1");
    method3();
  } 
  void method3() {
    System.out.println("blue 3");
  }
}

class Moo extends Blue {
  void method2() {
    super.method3();
    System.out.println("moo 2");
    this.method3();
  } 
  void method3() {
    System.out.println("moo 3");
  }
}

class Crew extends Moo {
  void method1() {
    System.out.println("crew 1");
  } 
  void method3() {
    System.out.println("crew 3");
  }
}


quite simple right? now, apply this:
Moo var1 = new Crew();
Blue var2 = new Moo();

and the question here is, what result would appear when var1.method1() is applied.
according to what sir told me first i have to check whether Moo has method1(), and if it doesnt (it doesnt), it should show compile time error. but no. i tried it and it works properly.
sorry for the lengthy message, and thanks beforehand!



Re: I got my finals coming up tomorrow and....

Sun Dec 28, 2008 10:46 am

blue 1
moo 3

Post a reply
  Related Posts  to : I got my finals coming up tomorrow and....
 Father of JAVA is coming to India     -