# Set X

## Descriptive Question

QID:
40

Find output or error:

``````class OOP2 {

int x(double d) {

System.out.println("one");

return 0;

}

String x(double d) {

System.out.println("two");

return null;

}

double x(double d) {

System.out.println("three");

return 0.0;

}

public static void main(String[] args) {

new OOP2().x(4.0)

}

} ``````

## Descriptive Question

QID:
39

Given:

``````public class X implements Z {

public String toString() {

return "I am X";

}

public static void main(String[] args) {

Y myY = new Y();

X myX = myY;

Z myZ = myX;

System.out.println(myZ);

}

}

class Y extends X {

public String toString() {

return "I am Y";

}

}

interface Z {}``````

What is the reference type of myZ and what is the type of the object it references?

## Descriptive Question

QID:
38

Find output or error:

``````class OOP1 {

void x (int i) {

System.out.println("one");

}

void x (String s) {

System.out.println("two");

}

void x (double d) {

System.out.println("three");

}

public static void main(String[] args) {

new OOP1().x (4.0);

}

} ``````

## Multiple Choice Question

QID:
37

Given:

``````interface I {
}

class A implements I {
}

class B extends A {
}

class C {
}

public class TestClass1 {
public static void main(String[] args) {
I i = new B();
B b = new B();
C c = new C();
if (i instanceof I)
System.out.println("i is a I");
if (b instanceof A)
System.out.println("b is a A");
if (c instanceof A)
System.out.println("c is a A");
}
}``````

What will be printed when the above code is compiled and run?

Select 1 option

A. It will not compile.

B. It will throw an exception when run.

C. i is a I
b is a A

D. i is a I

E. b is a A

F. c is a A

## Multiple Choice Question

QID:
36

Consider the following code:

``````class Super { static String ID = "SUPER"; }

class Sub extends Super{

static { System.out.print("In Sub"); }

}

public class Test{

public static void main(String[] args){

System.out.println(Sub.ID);

}

}``````

What will be the output when class Test is run?

Select 1 option

A. It will print In Sub and SUPER.

B. It will print SUPER.

C. Depends on the implementation of JVM.

D. It will not even compile.

E. None of the above.
{"ft_lang_label":"__label__en","ft_lang_prob":0.6373136,"math_prob":0.49072993,"size":2134,"snap":"2021-04-2021-17","text_gpt3_token_len":636,"char_repetition_ratio":0.16056338,"word_repetition_ratio":0.12755102,"special_character_ratio":0.34864104,"punctuation_ratio":0.18533605,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9727457,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-11T22:41:29Z\",\"WARC-Record-ID\":\"<urn:uuid:f230d7e1-7f41-4a2c-b7c1-ff670551fd46>\",\"Content-Length\":\"59082\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:322ca752-b443-47d0-95f9-d9ff07752883>\",\"WARC-Concurrent-To\":\"<urn:uuid:2bb5b050-4278-4174-a17b-93dff688d75d>\",\"WARC-IP-Address\":\"35.213.179.33\",\"WARC-Target-URI\":\"https://javajee.com/q-a-sets/set-x?page=3\",\"WARC-Payload-Digest\":\"sha1:U6RCPDUWK5HELK2XKI4HPRIM6YVFF6H7\",\"WARC-Block-Digest\":\"sha1:PEYNGJTCMFJD7RVNYXXDHSPBOWJO3JCF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618038065492.15_warc_CC-MAIN-20210411204008-20210411234008-00393.warc.gz\"}"}