File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
    Bookmark Topic Watch Topic
  • New Topic

Thangaraj S.

 
Thangaraj Selvamani
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Can any one give be the explanation for the code above and y it prints the output as parent


class Parent {
String message = "parent";
void say() {
System.out.println(message);
}
}

class Child extends Parent {
String message = "child";

}

public class ScjpTest3 {
public static void main(String[] args) {
new Child().say();
}
}
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Welcome to JavaRanch.

The way JavaRanch works is not just to give out answers, but to help people understand what's going on. So: What is the output, and why do you think that is? Where is it different from what you thought it would be? Can you think why?

We also have a collection of tips on how to get the most out of the Saloon: HowToAskQuestionsOnJavaRanch, in particular UseAMeaningfulSubjectLine.
 
Thangaraj Selvamani
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Sorry for the mistake... im new to this site...
here after i will give correct and reasonable title...

ya..i got the explanation for that code...
thanks for the links... will go through it...
thanks...
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
 
I agree. Here's the link: http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic