• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Overridden method

 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Why Line6 is not valid override as per whizlabs mock exam
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because amethod in OtherTest is private.
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stephan. This is from Whizlabs. Drag and Drop one of the following to Line # 8 and 10 so that given program compile and run
I. private int amethod(float i) {return 0;}
II. void amethod(int i) throws RuntimeException
I was thinking that answer would beBut, the answer is..Why ?
 
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When we write method in the super class as private
and override using another method in subclass
it is not considered overriding at all as the private method is not accessible to the subclass
and
throwing RuntimeException by overriding method is allowed even if the superclass method does not throw exception

for this you have to check out rules for overriding neatly

happy preparation
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prasad, Question doesn't refer anything about overriding..All it says is "compile & run"
 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harikrishna Gorrepati wrote:Hi Prasad, Question doesn't refer anything about overriding..All it says is "compile & run"


I know friend
but read the rules for overriding and you will come to know what the problem is
happy preparation
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have gone through all rules. Anyways, overriding rule doesn't apply here in this code. Let me put it this way. Even if I use either 2nd or 3rd code snippet, It compiles & runs fine. Please advice.
 
Ranch Hand
Posts: 186
Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harikrishna Gorrepati wrote:I have gone through all rules. Anyways, overriding rule doesn't apply here in this code. Let me put it this way. Even if I use either 2nd or 3rd code snippet, It compiles & runs fine. Please advice.



this time you are right harikrishna...
 
Stephan van Hulst
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I may, I have seen lots of really poor examples of code from WhizLabs. I don't know if they come highly recommended, but from all their code I've seen posted on this site, I would never even consider using them.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:If I may, I have seen lots of really poor examples of code from WhizLabs. I don't know if they come highly recommended, but from all their code I've seen posted on this site, I would never even consider using them.



Agree. In my opinion best would be the K&B Guide (CD)+ExamLab. On exam- there are tricky questions but few are at times easier.
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harikrishna Gorrepati wrote:I have gone through all rules. Anyways, overriding rule doesn't apply here in this code. Let me put it this way. Even if I use either 2nd or 3rd code snippet, It compiles & runs fine. Please advice.


Harikrishna Gorrepati, your answer also correct as like one they provided. But, they may want not to use the same code snaps for the two blanks.

Mu personal experience, don't use Whizlabs, I used it for my SCWCD preparation, but, not worth and making us confusing. There are many other useful mocks, like ExamLab. Use then as a study guide. This is my personal experience!
reply
    Bookmark Topic Watch Topic
  • New Topic