File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Problem regarding oops concept Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem regarding oops concept" Watch "Problem regarding oops concept" New topic

Problem regarding oops concept

sandeep patrudu

Joined: Feb 22, 2007
Posts: 6
Hi everyone,
I cannot figure it out why it is printing "Sub" in the Output even we are a passing a "null" parameter to foo()method in the below given code:

class Super{}

class Sub extends Super{


public class Test{

public void foo(Sub sub){

public void foo(Super sup)

public static void main(String args[]){

new Test().foo(null);
marc weber

Joined: Aug 31, 2004
Posts: 11343

See What is a most-specific method? from our SCJP FAQ (and note the last line of that answer).

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sandeep patrudu

Joined: Feb 22, 2007
Posts: 6
Hi Marc,
Thanks Marc for your reply.
I agree. Here's the link:
subject: Problem regarding oops concept
It's not a secret anymore!