Friday, May 24, 2013

Java Logic Questions Part - III

Posted by Sharath Chandra
Question  5:

public class A  extneds SuperClass {

public static void main(String []s) {
SuperClass sc = new A();
sc.m1();

}

@overridden
public static void m1() {
System.out.println(" Inside Child Class's m1()");
}

}

class SuperClass {

public static void m1() {
System.out.println(" Inside SuperClass's m1()");
}

}

Question 6:

public class A  extneds SuperClass {

public static void main(String []s) {
 if( (ArrayList) null == (Map) null)
     System.out.println (" Yes - Null is not specific to Object - Null is Unique" );
else 
     System.out.println (" No - Null is specific to Object - Null is not Unique" );
}
}

Result? 

|
|
|
|
|
|
|
|


|
|
|
|
|
|
|
|


|
|
|
|
|
|
|
|


|
|
|
|
|
|
|
|


|
|
|
|
|
|
|
|


Question 5: 
Answer
It will print 

 Inside SuperClass's m1()

Because m1 is a static method - and this concept is called as DataHiding.

Question 6:
Answer
It will print 

Yes - Null is not specific to Object - Null is Unique

Null is a unique reference.

Please share it because - Sharing is Gaining in Knowledge

PART - I CLICK HERE
PART - II CLICK HERE