Welcome Guest | Sign in | Register
Flow Control - Discussion Page For Q.2809 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Flow Control > Questions and Answers

Q: What is the output of the following code:

public class Example10 {
public static void main(String[] argv) {
SubExample2 se = new SubExample2();
se.showTitle();

}
}

class SubExample1{
String Name;

public SubExample1(String n) {
Name = n;
}

public void showName() {
System.out.println("Name is " + Name);
}
}

class SubExample2 extends SubExample1 {
public void setName(String nn) {
Name = nn;
}
}

What is the output of the above given code :
A. n B. nn
C. null D. Unresolved compilation problem:

Answer and Explanation

Answer:Unresolved compilation problem:

Explanation:
Since constructor of the SubExample1 class has a parameterized constructor that's why the "Name" value is undefined in this case.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.