File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overridden method

 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Why Line6 is not valid override as per whizlabs mock exam
 
Stephan van Hulst
Bartender
Pie
Posts: 4846
34
Chrome Netbeans IDE Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because amethod in OtherTest is private.
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • 0
  • Mark post as helpful
  • send pies
  • 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 ?
 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
swaraj gupta
Ranch Hand
Posts: 182
C++ Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • 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
Bartender
Pie
Posts: 4846
34
Chrome Netbeans IDE Windows
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Mohamed Sanaulla
Saloon Keeper
Pie
Posts: 3159
33
Google App Engine Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic