SCJP Module-1 Question-27

The Sample example given below will test your understanding about the abstraction and Inheritance in Java.

 
 

Share on Google+Share on Google+

SCJP Module-1 Question-27

Ads

The Sample example given below will test your understanding about the abstraction and Inheritance in Java.

Given a sample code:

1    public class Test1 {
2    String greet;
3    int value;

4    public Test1() {
5    greet = " India";
6    System.out.print(" " + greet);
    }

7    public Test1(int value) {
8    this.value = value;
9    greet = "Hello";
10  System.out.println(" " + greet);
    }

11  public static void main(String[] args) {
12  new Test1();
13  new Test1(1);
}}

What will be the result? Choose the correct option?

(A) Compilation error at line no 5.
(B) Hello India
(C) India Hello
(D) India India

Answer:

(C)

Advertisements

Posted on: July 21, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles