Share on Google+Share on Google+

SCJP Module-1 Question-27

Advertisement
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

Advertisement

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

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.