This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Can non abstract methods can access abstract methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Can non abstract methods can access abstract methods" Watch "Can non abstract methods can access abstract methods" New topic
Author

Can non abstract methods can access abstract methods

Satyajeet Kadam
Ranch Hand

Joined: Oct 19, 2006
Posts: 215
I am preapring for Java interview, I came across this question.
Q) when you declare a method as a abstract, can other non abstract methods can access it?
Ans)Yes,other non abstract methods can access a method that you declare as a abstract.

I think this anwer is wrong.

Q1)Please correct me if i am wrong?





Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18104
    
  39

Try...




And "access" is the wrong word -- as you technically can't access anything that doesn't exist -- maybe "allowed to call" is better.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Oguzhan Acargil
Greenhorn

Joined: Apr 16, 2010
Posts: 6

Try to google Template pattern...

A subclass implements abstract methods. In order to access non abstract methods in an abstract class, you have to intiate it with a subclass. Thats way there is no problem.

I wish it is clear
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Yesss.....Non-abstract method can call Non-abstract method

Reason :- Compiler ensures that we cannot create an object for an abstract class.
This means whenever we could call that non-abstract method, it would be called only from the class which extends the abstract class.
In that case , the class which would extend the abstract class has to implement the abstract method.
So it is possible to call it !!!



SCJP 6.0 96%

(Connecting the Dots ....)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can non abstract methods can access abstract methods
 
Similar Threads
Access Modifiers
few questions
Examlab generics question
Abstract Classes / Methods
Java Grammer/ Reg Ex For method identification