What is the result?

Given:
<code>
public class SampleClass {
public static void main(String[] args) {
AnotherSampleClass asc = new AnotherSampleClass();
SampleClass sc = new SampleClass();
sc = asc;
System.out.println(“sc: ” + sc.getClass());
System.out.println(“asc: ” + asc.getClass());
}}
class AnotherSampleClass extends SampleClass {
}
</code>
What is the result?

Given:

public class SampleClass {
public static void main(String[] args) {
AnotherSampleClass asc = new AnotherSampleClass();
SampleClass sc = new SampleClass();
sc = asc;
System.out.println("sc: " + sc.getClass());
System.out.println("asc: " + asc.getClass());
}}
class AnotherSampleClass extends SampleClass {
}

What is the result?

A.
sc: class Object
asc: class AnotherSampleClass

B.
sc: class SampleClass
asc: class AnotherSampleClass

C.
sc: class AnotherSampleClass
asc: class SampleClass

D.
sc: class AnotherSampleClass
asc: class AnotherSampleClass



Leave a Reply 1

Your email address will not be published. Required fields are marked *


sully

sully

a repeated question