Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Private method overriden...

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
The answer for the question is "D", Why not "E" Becuase you can't override PRIVATE method also.Pls explaint to me.

thanks
Raghu.K

To disallow a class member function to be overriden, which of the following modifiers should be used?
A) PUBLIC
B) DEFAULT
C) PROTECTED
D) FINAL
E) PRIVATE
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can private method be overridden?
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is the use of private method overridden?
 
Ranch Hand
Posts: 1249
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Sujittt Tripathyrr:
So what is the use of private method overridden?



No Use offcourse....
 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

There is nothing called "overridden private method" as they cannot be overridden. The only thing possible is defining a new method with same signature and access modifier.

Bye & Regards,
Praveen
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[this is how i understand overriding, pls correct me if im wrong]

To disallow a class member function to be overriden, which of the following modifiers should be used?
A) PUBLIC
B) DEFAULT
C) PROTECTED
D) FINAL
E) PRIVATE



the answer is final ; because final by definition means that it cannot be change. like final class cant be extended. in this case, the final method can only be inheritted by the subclas but not overridden.

as for the access modifier private; when you inherit a superclass, the subclass cannot use/see its private variables/method. thus, private method that belongs to a superclass cant be overidden, but a subclass can create a method that has the same name and signature, like the private method, but this is not overidding.
[ August 03, 2006: Message edited by: Firman Drage ]
 
There's a hole in the bucket, dear Liza, dear Liza, a hole in the bucket, dear liza, a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!