This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud and have Kyle Brown, Bobby Woolf and Joseph Yodor on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Marcus exam 3 q 17

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question 17)
Which of the following statements are true?

1) static methods do not have access to the implicit variable called this
2) a static method may not be overriden
3) a static method may not be overriden to be non-static
4) a static method may not be overloaded

Answer given is 1 and 3. according to me 2 is also the answer.It is hidden and not overriden
What say???
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Static method can very well be overriden. So 2 is wrong
Regards
Anwar
------------------
 
Rajani Deshpande
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No Anwar,
They can never be over ridden. you can hide them by defining the same method in a subclass. but u can always access them using the class name. So it is proper to say static methods are hidden and improper to say they are overridden.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My understanding is that static methods are implicitly final. So, there is no question of overriding a static method.
well, what do other's say about this??
-sath
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A parent class and a child class can have static funcions with same signature and return type. This means static methods can be overridden. So if you call a static method of a class and the method is not in that class, it tries to find a funcion with the same signature up in the class hierarchy.
But there is a slight problem when you use objects to call static fucntions. Think of this situation. A static method amethod() in class A is overridden in sub class B. You create an object of B and assign it to an object variable of A. Now you call the static method using A.amethod(). It picks up the amethod() of the parent, not of the child. If amethod() were non static,
it would have picked up the amethod() of B. The reason is
static methods are resolved at compilation and compiler honours the type of object variable.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic