About Question com.enthuware.ets.scjp.v6.2.624 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
aruna1982
Posts: 5
Joined: Sat Feb 15, 2014 4:31 pm
Contact:

About Question com.enthuware.ets.scjp.v6.2.624 :

Post by aruna1982 »

in the trial exam, explanation has the following code. Doesn't m1 method in class a missing void?

Code: Select all

Another concept (although not related to this question but about static methods) is that static methods are never overridden. They are HIDDEN or SHADOWED just like static or non-static fields. For example,

class A
{
  int i = 10;
  public static m1(){  }
  public void m2() { }
}
class B extends A
{
  int i = 20;
  public static void m1() {  }
  public void m2() { }
}


Here, UNLIKE m2, m1() of B does not override m1() of A, it just shadows it, as proven by the following code: A a = new B(); System.out.println(a.i) //will print 10 instead of 20 a.m1(); //will call A's m1 a.m2(); //will call B's m2 as m2() is not static and so overrides A's m2()

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.624 :

Post by admin »

Yes, it is. Fixed.

thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests