What is the result?

Given the class definitions: And the code fragment of the main() method, What is the result?

Given the class definitions: And the code fragment of the main() method, What is the result?

A.
Java Java Java

B.
Java Jeve va

C.
Java Jeve ve

D.
Compilation fails



Leave a Reply 11

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


noname

noname

just C. I test with code

public class Q103 {
public static void main(String[] args) {
List lst = new ArrayList();
lst.add(new Alpha());
lst.add(new Beta());
lst.add(new Gamma());
for (Alpha alpha : lst) {
System.out.println(alpha.doStuff(“Java”));
}
}
}

class Alpha {
public String doStuff(String msg){
return msg;
}
}

class Beta extends Alpha{
public String doStuff(String msg){
return msg.replace(“a”, “e”);
}
}

class Gamma extends Beta{
public String doStuff(String msg){
return msg.substring(2);
}
}

ARJIT GAUTAM

ARJIT GAUTAM

Run the programs. Its B

import java.util.ArrayList;

public class Person {
public static void main(String[] args) {
ArrayList lst = new ArrayList();
lst.add(new Alpha());
lst.add(new Beta());
lst.add(new Gamma());
for (Alpha alpha : lst) {
System.out.println(alpha.doStuff(“Java”));
}
}
}

class Alpha {
public String doStuff(String msg) {
return msg;
}
}

class Beta extends Alpha {
public String doStuff(String msg) {
return msg.replace(‘a’, ‘e’);
}
}

class Gamma extends Beta {
public String doStuff(String msg) {
return msg.substring(2);
}
}

Venk Hatta

Venk Hatta

Completed 1Z0-803 exam few days ago! Scored 90% (the passing line is 63% now)!!

Had 70 questions in my actual 1Z0-803 test.

Most of the questions are on Giving Code … tell the result, insert CODE, choose the best option …etc.

Only few questions on Java: advantages of the Java exception mechanism, benefits of using ArrayList over array, valid types for switch, Java Exception classes, two-dimensional array, improve the encapsulation of a class, java class declaration … and so on.

Used valid 1Z0-803 dumps from PassLeader (http://www.passleader.com/1z0-803.html) (272q VCE and PDF), almost all questions were same as my 1Z0-803 exam, valid enough for passing until now!