Total members 11892 |It is currently Sat Sep 21, 2024 10:30 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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!




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

blue 1
moo 3

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

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









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com