Home Tutorial Java Scjp Part1 SCJP Module-1 Question-27

 
 

Share on Google+Share on Google+
SCJP Module-1 Question-27
Posted on: July 21, 2010 at 12:00 AM
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)

Advertisement

Related Tags for SCJP Module-1 Question-27:


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.

Posted on: July 21, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com