Examen Java Programmer I
Examen Java Programmer I
0 Given:
public class Natural {
private int i;
void disp() {
while (i <= 5) {
for (int i = 1; i <= 5;) {
System.out.print(i + " ");
i++;
}
i++;
}
}
A. Prints 1 2 3 4 5 once
B. Prints 1 3 5 once
E. Compilation fails
La respuesta D es CORRECTA.
1 Given:
class Base {
// insert code here
}
A.
private int num;
B.
public int num;
protected public int getNum() {
return num;
}
protected public void setNum(int num) {
this.num = num;
}
C.
private int num;
public int getNum() {
return num;
}
private void setNum(int num) {
this.num = num;
}
D.
protected int num;
public int getNum() {
return num;
}
E.
protected int num;
La respuesta A es CORRECTA
La respuesta D es CORRECTA
2 Given:
class Overloading {
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;
}
A. One
B. Two
C. Three
D. Compilation fails.
La respuesta D es CORRECTA
3 Given:
public class Whizlabs {
switch (s) {
case "a":
System.out.println("simaple A ");
default:
System.out.print("default ");
case "A":
System.out.print("Capital A ");
}
}
}
A. simaple A
B. Capital A
D. simaple A default
E. Compilation fails.
La respuesta es B CORRECTA.
Which three lines, when inserted independently at line n1, cause the program to print a 0
balance?
A. this.amount = 0;
B. amount = 0;
C. acct(0);
D. acct.amount = 0;
E. acct.getAmount() = 0;
F. acct.changeAmount(0);
G. acct.changeAmount(-acct.amount);
H. acct.changeAmount(-acct.getAmount());
La respuesta D es CORRECTA.
La respuesta G es CORREPTA.
La respuesta H es CORREPTA.
5 Given:
public class Test {
static String[][] arr = new String[3][];
Which code fragment, when inserted at line //insert code here, enables the code to print COJ?
A.
int i = 0;
for (String[] sub : arr) {
int j = sub.length - 1;
for (String str : sub) {
System.out.println(str[j]);
i++;
}
}
B.
for (int i = 0; i < arr.length; i++) {
int j = arr[i].length - 1;
System.out.print(arr[i][j]);
}
C.
int i = 0;
for (String[] sub : arr[][]) {
int j = sub.length;
System.out.print(arr[i][j]);
i++;
}
D.
for (int i = 0; i < arr.length - 1; i++) {
int j = arr[i].length - 1;
System.out.print(arr[i][j]);
i++;
}
La respuesta B es CORRECTA.
6 Given the code fragment:
public static void main(String[] args) {
int ii = 0;
int jj = 7;
for (ii = 0; ii < jj - 1; ii = ii + 2) {
System.out.print(ii + " ");
}
}
A. 2 4
B. 0 2 4 6
C. 0 2 4
D. Compilation fails
La respuesta C es la CORRECTA.
7 Given:
A. null
B. Compilation fails
La respuesta C es CORRECTA.
8 Given:
TestApp.java
A.
at TestApp.doList(TestApp.java: 14)
at TestApp.main(TestApp.java: 6)
B.
at TestApp.doList(TestApp.java: 14)
at TestApp.main(TestApp.java: 6)
C.
D.
La respuesta D es CORRECTA.
C.
System.out.print(LocalTime.now());
D.
System.out.print(LocalTime.today());
La respuesta C es CORRECTA.
10 Given:
public class Test {
javac Test.Java
A. Success
B. Failure
C. Compilation fails.
La respuesta B es CORRECTA.
11 Given:
class Cake {
int model;
String flavor;
Cake() {
model = 0;
flavor = "Unknown";
}
}
A.
0 unknown
0 unknown
B.
1200 Strawberry
1200 Strawberry
C.
1200 Strawberry
1230 Chocolate
D. Compilation fails
La respuesta C es CORRECTA.
12 Given:
int i, j = 0;
i = (3 * 2 + 4 + 5);
j = (3 * ((2 + 4) + 5));
System.out.println("i:" + i + "\nj:" + j);
A.
i:16
j:33
B.
i.15
j:33
C.
i:33
j:23
D.
i:15
j:23
La respuesta A es CORRECTA.
La respuesta D es CORRECTA.
A.
1.0, 1
B.
1.0f, 1
C.
7.33, 7
D. Compilation fails
La respuesta A es CORRECTA.
15 Given:
public class Equal {
A.
true, false
B.
false, true
C.
true, true
D.
false, false
La respuesta B es CORRECTA.
16 Given:
A.
B.
C.
11
D.
10
E. Compilation fails
La respuesta B es CORRECTA.
C. Can be read and written from this class and its subclasses only within the same package
D. Can be read and written from this class and its subclasses defined in any package
La respuesta D es CORRECTA.
class Student {
int rollnumber;
String name;
List cources = new ArrayList();
Which code fragment, when inserted at line // insert code here, enables class Test to print 123 :
Fred : [Java, C]?
A.
B.
public void Student(int i, String name, List cs) {
/* initialization code goes here */
}
C.
D.
La respuesta C es CORRECTA.
19 Given:
public class Circle {
double radius;
public double area;
public Circle(double r) {
radius = r;
}
class App {
The class is poorly encapsulated. You need to change the circle class to compute and return the
area instead.
Which two modifications are necessary to ensure that the class is being properly encapsulated?
La respuesta A es CORRECTA.
La respuesta B es CORRECTA.
20 Given :
B.
C.
D. Compilation fails
La respuesta E es la CORRECTA.
A.
ArrayList<Animal> myList = new ArrayList<>();
myList.add(new Tiger());
B.
ArrayList<Hunter> myList = new ArrayList<>();
myList.add(new Cat());
C.
ArrayList<Hunter> myList = new ArrayList<>();
myList.add(new Tiger());
D.
ArrayList<Tiger> myList = new ArrayList<>();
myList.add(new Cat());
E.
ArrayList<Animal> myList = new ArrayList<>();
myList.add(new Cat());
La respuesta D es CORRECTA.
A.
int[][] arr = null;
B.
int[][] arr = new int[2];
C.
int[][] arr = new int[2][];
D.
E.
F.
int[][] arr = new int[0][4];
La respuesta C es CORRECTA.
La respuesta E es CORRECTA.
A. This is not the only valid for loop construct; there exits another form of for loop constructor.
B. The expression expr1 is optional. it initializes the loop and is evaluated once, as the loop begin.
C. When expr2 evaluates to false, the loop terminates. It is evaluated only after each iteration
through the loop.
D. The expression expr3 must be present. It is evaluated after each iteration through the loop.
La respuesta A es CORRECTA.
La respuesta B es CORRECTA.
A.
int e = 0; e <= 4; e++
B.
int e = 0; e < 5; e += 2
C.
int e = 1; e <= 5; e += 1
D.
int e = 1; e < 5; e +=2
La respuesta B es la CORRECTA.
25 Given:
public class X implements Z {
public String toString() {
return "X ";
}
class Y extends X {
interface Z {
A.
XXX
B.
XYX
C.
YYX
D.
YYY
La respuesta D es la CORRECTA.
26 Given:
public class ComputeSum {
public int x;
public int y;
public int sum;
void updateSum() {
sum = x + y;
}
}
Which three members must have the private access modifier to ensure that this invariant is
maintained?
A. The x field
B. The y field
La respuesta C es CORRECTA.
La respuesta E es CORRECTA.
La respuesta F es CORRECTA.
27 Given the code fragment:
int[] array = {1, 2, 3, 4, 5};
Process all the elements of the array in the reverse order of entry.
E. Requirement 3 CANNOT be implemented by using either the enhanced for loop or the standard
for loop.
La respuesta es B CORRECTA.
La respuesta D es CORRECTA.
28 Given:
A.
120
B.
120D
La respuesta E es CORRECTA.
C. It can be overloaded.
D. The default constructor of a subclass always invokes the no-argument constructor of its
superclass.
La respuesta D es CORRECTA
30
Which statement is true about Java byte code?
B. It can run on any platform only if it was compiled for that platform.
C. It can run on any platform that has the Java Runtime Environment.
E. It can run on any platform only if that platform has both the Java Runtime Environment and a
Java compiler.
La respuesta C es CORRECTA.
A.
28false29
true
B.
C.
true
true
D. compilation fails
La respuesta C es la CORRECTA.
32 Given the code fragment:
Which code fragment, when inserted at // insert code here, enables the code to compile and and
print a b c?
A.
List update (String[] strs)
B.
static ArrayList update(String[] strs)
C.
static List update (String[] strs)
D.
static void update (String[] strs)
E.
ArrayList static update(String[] strs)
La respuesta C es CORRECTA.
33 What is the name of the Java concept that uses access modifiers
to protect variables and hide them within a class?
A. Encapsulation
B. Inheritance
C. Abstraction
D. Instantiation
E. Polymorphism
La respuesta A es CORRECTA
34 Given:
javac Palindrome.java
A. Compilation fails
Paildrome
D.
Wow
E.
Mom
La respuesta B es CORRECTA.
35 Given:
public class Access {
private int x = 0;
private int y = 0;
x:1 y:2
x:3 y:4
B.
x:0 y:0
x:3 y:4
C.
x:1 y:2
x:0 y:0
D.
x:0 y:0
x:0 y:0
La respuesta B es CORRECTA.
B. Line 7
C. Line 8
D. Line 9
E. Line 10
F. Line 11
37 Given:
int num;
A. 1
B. 2
C. 3
D. 4
La respuesta A es CORRECTA.
A.java
public class A {
B.java
public class B {
C.java
import java.io.*;
package p1;
class C {
La respuesta A es CORRECTA.
39 What is the proper way to defined a method that take two int
values and returns their sum as an int value?
A.
int sum(int first, int second) { first + second; }
B.
int sum(int first, second) { return first + second; }
C.
sum(int first, int second) { return first + second; }
D.
int sum(int first, int second) { return first + second; }
E.
void sum (int first, int second) { return first + second; }
La respuesta D es CORRECTA.
String name;
int age;
Test.java
public class Test {
Which code fragment, when inserted at line n1, enables the code to print Hank?
A.
checkAge(iList, () -> p.getAge() > 40);
B.
checkAge(iList, Person p -> p.getAge() > 40);
C.
D.
La respuesta C es CORRECTA.
011
B.
012
C.
123
D.
000
La respuesta A es la CORRECTA.
42 Given:
MainTest.java
public class MainTest {
and commands:
javac MainTest.java
java MainTest 1 2 3
A.
int main 1
B.
Object main 1
C.
String main 1
D. Compilation fails
La respuesta C es CORRECTA.
B. Encapsulation ensures that classes can be designed so that their methods are inheritable.
C. Encapsulation ensures that classes can be designed with some fields and methods declared as
abstract.
D. Encapsulation ensures that classes can be designed so that if a method has an argument
MyType x, any subclass of MyType can be passed to that method.
La respuesta A es la CORRECTA.
A.
B.
C.
D.
La respuesta A es la CORRECTA.
A.
Student student1;
B.
Student student1 = Student.new();
C.
Student student1 = new Student();
D.
Student student1 = Student();
La respuesta C es CORRECTA.
}
}
La respuesta C es CORRECTA.
La respuesta D es CORRECTA.
47 Given:
A.
: Fresco
B.
null : Fresco
C.
Fresco : Fresco
La respuesta B es CORRECTA.
48 Given:
class Dog {
Dog() {
try {
throw new Exception();
} catch (Exception e) { }
}
}
class Test {
How many objects have been created when the line // do complex stuff is reached?
A. Two
B. Three
C. Four
D. Six
La respuesta A es CORRECTA.
49 Given:
public class App {
A.
true false
B.
true null
C. Compilation fails
String name;
this(); // line n1
setName(name);
Person(name); // line n2
setAge(age);
System.out.println(p2.show());
A.
Jesse 25
Walter 52
La respuesta D es CORRECTA.
51 Given:
DoInterface.java
package p1;
Test.java
package p3;
import p1.DoInterface;
La respuesta C es CORRECTA.
A. These are exceptional conditions that a well-written application should anticipate and recover
from.
B. These are exceptional conditions that are external to the application, and that the application
usually cannot anticipate or recover from.
C. These are exceptional conditions that are internal to the application, and that the application
usually cannot anticipate or recover from.
E. Every class that is a subclass of Exception, excluding RuntimeException and its subclasses, is
categorized as checked exception.
La respuesta A es CORRECTA.
La respuesta E es CORRECTA.
53 Given:
A. Found 3 at 2
B. Found 3 at 3
C. Compilation fails
La respuesta C es CORRECTA.
54 Given the code fragment:
if (sb.equals(s)) {
System.out.println("Match 1");
} else if (sb.toString().equals(s.toString())) {
System.out.println("Match 2");
} else {
System.out.println("No Match");
}
}
A.
Match 1
B.
Match 2
C.
No Match
La respuesta B es CORRECTA.
A.
for (int i : intArr) {
System.out.print(intArr[i] + " ");
}
B.
for (int i : intArr) {
System.out.print(i + " ");
}
C.
for (int i = 0; intArr) {
System.out.print(intArr[i] + " ");
i++;
}
D.
for (int i = 0; i < intArr.length; i++) {
System.out.print(i + " ");
}
E.
for (int i = 0; i < intArr.length; i++) {
System.out.print(intArr[i] + " ");
}
La respuesta B es CORRECTA.
La respuesta E es CORRECTA.
56 Which of the following can fill in the blank in this code to make it
compile? (Select 2 options.)
La respuesta A es CORRECTA.
La respuesta C es CORRECTA.
interface Contract {
}
objs.add(c1);
objs.add(c2);
objs.add(s1); // line n2
A.
Super
Sub
Sub
B.
Contract
Contract
Super
La respuesta A es CORRECTA.
A.
1:2:3:4:5:
B.
1:2:3:
C. Compilation fails.
La respuesta A es CORRECTA.
class Candidate {
String name;
int age;
James age: 20
Williams age: 32
A.
B.
C.
D.
La respuesta C es CORRECTA.
60 Given:
A.
box
B.
nbo
C.
bo
D.
nb
La respuesta E es CORRECTA.
61 Given the code fragment:
A.
B.
[Robb, Rick]
C.
La respuesta A es CORRECTA.
A.
-6
B.
-4
C.
-5
D.
E.
F. Compilation fails
La respuesta C es CORRECTA.
A. Only I.
B. Only II.
E. ALL
La respuesta D es CORRECTA.
A.
543210
B.
54321
C.
421
D.
E. Nothing is printed
La respuesta D es CORRECTA.
System.out.println(planets.length);
System.out.println(planets[1].length());
}
A.
B.
C.
7
D.
E.
F.
21
La respuesta E es CORRECTA.
A.
B.
C.
D.
double y1 = 203.22;
int y2 = 100;
La respuesta D es CORRECTA.
67 Consider
La respuesta D es CORRECTA, la cadena al ser un número que no es entero genera una excepción.
sb.deleteAll();
B.
sb.delete(0, sb.size());
C.
sb.delete(0, sb.length());
D.
sb.removeAll();
La respuesta C es CORRECTA.
A. NullPointerException
B. NegativeArraySizeException
C. ArrayIndexOutOfBoundsException
D. IndexOutOfBoundsException
La respuesta B es CORRECTA.
70 Given:
Acc.java
package p1;
public class Acc {
int p;
private int q;
protected int r;
public int s;
}
Test.java
package p2;
import p1.Acc;
La respuesta B es CORRECTA.
71 Given:
A.
5:5
B.
6:4
C.
6:5
D.
5:4
La respuesta A es CORRECTA.
72 Given:
log3:false
log4:true
B.
log3:true
log4:true
C.
log3:true
log4:false
D.
log3:false
log4:false
La respuesta B es CORRECTA
B. Line 22
C. Line 23
D. Line 24
E. Line 25
La respuesta B es CORRECTA.
interface Runnable{
public void run();
}
A.
Runnable run = () -> {System.out.println("Run");};
B.
Runnable run = () -> System.out.println("Run");
C.
Runnable run = () > System.out.println("Run");
D.
Runnable run = > System.out.println("Run");
75 Given the following code for the classes MyException and Test:
MyException.java
Test.java
A.
A
B.
C.
Either A or B
D.
AB
La respuesta B es CORRECTA.
76 Given:
A.
C.
D.
La respuesta D es CORRECTA.
77 Given:
class Jump {
javac Jump.java
B.
C.
D.
E. Compilation fails
La respuesta D es CORRECTA
79 Given:
package p1;
A.
p1.Test.class
0.0
B
0.000000
C.
null
0.0
D. Compilation fails
La respuesta C es CORRECTA
80 Given:
DoInterface.java
package p1;
DoClass.java
package p3;
public class DoClass implements DoInterface{
int x1, x2;
DoClass(){
this.x1 = 0;
this.x2 = 10;
}
public void m1(int p1) { x1+=p1; System.out.println(x1); } // line n2
public void m2(int p1) { x2+=p1; System.out.println(x2); }
}
Test.java
package p2;
import p1.*;
import p3.*;
class Test {
A.
100
210
La respuesta D es CORRECTA
Which code fragment, when inserted at line n1, enables the App class to print Equal?
A.
B.
if (str1.equalsIgnoreCase(str2))
C.
D.
if (str1.toLowerCase() == str2.toLowerCase())
La respuesta B es CORRECTA
82 Given:
class StaticField {
static int i = 7;
A.
10 10
B.
89
C.
98
D.
7 10
La respuesta A es CORRECTA.
A. Improves the program structure because the error handling code is separated from the normal
program function
B. Provides a set of standard exceptions that covers all the possible errors
C. Improves the program structure because the programmer can choose where to handle
exceptions
D. Improves the program structure because exceptions must be handled in the method in which
they occurred
E. Allows the creation of new exceptions that are tailored to the particular program being created
La respuesta A es CORRECTA.
La respuesta C es CORRECTA.
La respuesta E es CORRECTA.
A.
B.
2014-05-04T00:00:00.000
C.
5/4/14T00:00:00.000
La respuesta D es CORRECTA.
85 A method is declared to take three arguments. A program calls
this method and passes only two arguments. What is the results?
A. Compilation fails.
E. The third argument is given the appropriate falsy value for its declared type. F) An exception
occurs when the method attempts to access the third argument.
La respuesta A es CORRECTA
System.out.println(planets);
System.out.println(planets[2]);
System.out.println(planets[2].moons);
}
planets
Earth
B.
[LPlanets.Planet;@15db9742
Earth
C.
[LPlanets.Planet;@15db9742
Planets.Planet@6d06d69c
D.
[LPlanets.Planet;@15db9742
Planets.Planet@6d06d69c
[LPlanets.Moon;@7852e922
E.
[LPlanets.Planet;@15db9742
Venus
La respuesta C es CORRECTA.
87 Give:
Test.java
class Alpha {
Alpha(String[] main) {
for (int ii = 0; ii < main.length; ii++) {
this.main[ii] = main[ii] + 5;
}
}
javac Test.java
java Test 1 2
A.
1525
B.
13
C. Compilation fails
D. An exception is thrown at runtime
La respuesta A es CORRECTA.
double discount = 0;
int qty = Integer.parseInt(args[0]);
// line n1;
If the value of the qty variable is greater than or equal to 90, discount = 0.5
If the value of the qty variable is between 80 and 90, discount = 0.2
Which two code fragments can be independently placed at line n1 to meet the requirements?
A.
if (qty >= 90) {discount = 0.5; }
if (qty > 80 && qty < 90) {discount = 0.2; }
B.
discount = (qty >= 90) ? 0.5 : 0;
discount = (qty > 80) ? 0.2 : 0;
C.
discount = (qty >= 90) ? 0.5 : (qty > 80) ? 0.2 : 0;
D.
if (qty > 80 && qty < 90) {
discount = 0.2;
} else {
discount = 0;
}
if (qty >= 90) {
discount = 0.5;
} else {
discount = 0;
}
E.
discount = (qty > 80) ? 0.2 : (qty >= 90) ? 0.5 : 0;
La respuesta A es CORRECTA.
La respuesta C es CORRECTA.
Assume that the system date is June 20, 2014. What is the result?
A.
date1 = 2014-06-20
date2 = 2014-06-20
date3 = 2014-06-20
B.
date1 = 06/20/2014
date2 = 2014-06-20
La respuesta A es CORRECTA.
90 Given:
class Mid {
Which two code fragments, when inserted at // insert code here, enable the code to compile and
print 12?
A.
B.
C.
Calc c = new Mid();
int n3 = c.findMid(n1, n2);
D.
Mid m1 = new Calc();
int n3 = m1.findMid(n1, n2);
E.
int n3 = Calc.findMid(n1, n2);
La respuesta A es CORRECTA.
La respuesta D es CORRECTA.
91 Given:
A.
123
B.
123xxx
C.
123456
D.
123456xxx
E. Compilation fails
La respuesta B es CORRECTA
92 Given:
public class ColorTest {
A.
Yellow
B.
Maroon
C. Compilation fails
La respuesta C es CORRECTA .
93 Given:
public class Triangle {
A.
Area is 6.0
B.
Area is 3.0
La respuesta D es CORRECTA.
A.
for (String c : colors) {
if (c.length() != 4) {
continue;
}
System.out.print(c + ", ");
}
B.
for (String c : colors[]) {
if (c.length() <= 4) {
continue;
}
System.out.print(c + ", ");
}
C.
for (String c : String[] colors) {
if (c.length() >= 4) {
continue;
}
System.out.print(c + ", ");
}
D.
for (String c : colors) {
if (c.length() >= 4) {
System.out.print(c + ", ");
continue;
}
}
La respuesta A es CORRECTA.
95 Given:
A.
true true
B.
true false
C.
false true
D.
false false
E. Compilation fails
La respuesta C es CORRECTA
A.
10 Hello World!
B.
Hello Universe!
C.
Hello World!
D. Compilation fails.
La respuesta A es CORRECTA
97 Given:
public class SuperTest {
class Shape {
public Shape() {
System.out.println("Shape: constructor");
}
public Square() {
super();
}
What should statement1, statement2, and statement3, be respectively, in order to produce the
result?
Shape: constructor
Square: foo
Shape: foo
A.
Square square = new Square("bar");
square.foo("bar");
square.foo();
B.
Square square = new Square("bar");
square.foo("bar");
square.foo("bar");
C.
Square square = new Square();
square.foo();
square.foo(bar);
D.
Square square = new Square();
square.foo();
square.foo("bar");
E.
Square square = new Square();
square.foo();
square.foo();
F.
Square square = new Square();
square.foo("bar");
square.foo();
La respuesta F es CORRECTA
E. None of above.
La respuesta B es CORRECTA
99 Given:
interface Pet {
}
A.
Pet a = new Dog();
B.
Pet b = new Pet();
C.
Dog f = new Pet();
D.
Dog d = new Beagle();
E.
Pet e = new Beagle();
F.
Beagle c = new Dog();
La respuesta A es CORRECTA
La respuesta D es CORRECTA
La respuesta E es CORRECTA
class DBConfiguration {
String user;
String password;
}
And,
Which code fragment must be inserted at line 6 to enable the code to compile?
A.
DBConfiguration f;
return f;
B.
return DBConfiguration;
C.
return new DBConfiguration();
D.
retutn 0;
La respuesta C es CORRECTA
101 Given
public class Test {
102 Given
public class Series {
A.
2 4 6 8 10 12
B.
2 4 6 8 10 12 14
C. Compilation fails
La respuesta E es la CORRECTA..
La respuesta C es la CORRECTA.
La respuesta D es la CORRECTA.
104 Given:
public class StringReplace {
A.
message = Hi everyone!
B.
message = Hi XvXryonX!
E.
message =
F.
message = Hi Xveryone!
La respuesta B es la CORRECTA
105 Given:
public class TestScope {
La respuesta A es la CORRECTA.
106 Given:
public class TestLoop {
public static void main(String[] args) {
float myarray[] = {10.20f, 20.30f, 30.40f, 50.60f};
int index = 0;
boolean isFound = false;
float key = 30.40f;
//line 7 insert code here
System.out.println(isFound);
}
}
Which code fragment, when inserted at line 7, enables the code print true?
A.
while(key == myarray[index++]){
isFound = true;
}
B.
while(index <= 4){
if(key == myarray[index]){
index++;
isFound = true;
break;
}
}
C.
while(index++ < 5){
if(key == myarray[index]){
isFound = true;
}
}
D.
while(index < 5){
if(key == myarray[index]){
isFound = true;
break;
}
index++;
}
La respuesta D es CORRECTA.
La respuesta A es CORRECTA.
La respuesta B es CORRECTA.
La respuesta D es CORRECTA.
A.
10 8 6 4 2 0
B.
10 8 6 4 2
E. Compilation fails
La respuesta A es CORRECTA.
109 Given:
public static void main(String[] args) {
String theString = "Hello World";
System.out.println(theString.charAt(11));
}
B.
La respuesta C es CORRECTA.
110 Given:
public class Whizlabs {
A.
2015-03-27
B.
2015-04-27
C.
2015-02-27
La respuesta A es CORRECTA.
A.
20
B.
25
C.
29
D. Compilation fails
La respuesta A es CORRECTA.
112 Given:
class Base {
A.
Base 30
B.
Overridden 20
C.
Overridden 20
Base 30
D.
Base 30
Overridden 20
La respuesta B es CORRECTA.
113 Which three statements are true about the structure of a Java
class?
A. A class can have only one private constructor.
B. A method can have the same name as a field.
La respuesta B es CORRECTA
La respuesta C es CORRECTA
La respuesta F es CORRECTA.
114 Given:
public class Test {
Which two modifications, made independently, enable the code to compile and run?
La respuesta C es CORRECTA.
La respuesta D es CORRECTA.
A.
13480.0
B.
13480.02
C. Compilation fails
La respuesta A es CORRECTA.
116 Given:
public class App {
A.
10 : 22 : 20
B.
10 : 22 : 22
C.
10 : 22 : 6
D.
10 : 30 : 6
La respuesta B es la CORRECTA.
La respuesta B es CORRECTA.
118 Given:
class Caller {
private void init() {
System.out.println("Initialized");
}
A.
Initialized
Started
B.
Initialized
Started
Initialized
C. Compilation fails
La respuesta C es CORRECTA.
119 Given:
interface Readable {
// line n4
}
B. At line n2 insert:
D. At line n4 insert:
La respuesta C es CORRECTA.
La respuesta D es CORRECTA.
120 Which usage represents a valid way of compiling java source file
with the name "Main"?
A. javac Main.java
B. java Main.class
C. java Main.java
D. javac Main
E. java Main
La respuesta A es CORRECTA.
121 Given:
public class MarkList {
int num;
A. 1
B. 2
C. 3
D. 4
La respuesta A es CORRECTA.
122 Given the code fragment?
public class Test {
}
Which method can be inserted at line // insert code here to enable the
code to compile?
A.
public int[] subArray(int[] src, int start, int end) {
return src;
}
B.
public int subArray(int src, int start, int end) {
return src;
}
C.
public int[] subArray(int src, int start, int end) {
return src;
}
D.
public int subArray(int[] src, int start, int end) {
return src;
}
La respuesta A es CORRECTA.
123 Given:
public class Msg {
A.
Good Day!
Good Luck!
B.
Good Day!
Good Day!
C.
Good Luck!
Good Day!
D.
Good Luck!
Good Luck!
E. Compilation fails
La respuesta A es CORRECTA.
124 Given:
class X {
int x1, x2, x3;
}
class Y extends X {
int y1;
Y() {
x1 = 1;
x2 = 2;
y1 = 10;
}
}
class Z extends Y {
int z1;
Z() {
x1 = 3;
y1 = 20;
z1 = 100;
}
}
La respuesta A es CORRECTA.
125 Given the code fragment:
int x = 100;
int a = x++;
int b = ++x;
int c = x++;
int d = (a < b) ? (a < c) ? a : (b < c) ? b : c;
System.out.println(d);
A.
100
B.
101
C.
102
D.
103
E. Compilation fails
La respuesta E es CORRECTA.
126 Which of the following can fill in the blank in this code to make it
compile?
Exam.java
public class Exam {
void method() {
}
}
OCAJP.java
public class OCAJP extends Exam{
_____ void method(){}
}
A. abstract
B. final
C. private
D. default
E. int
La respuesta B es CORRECTA.
La respuesta A es CORRECTA.
La respuesta B es CORRECTA.
128 Given
public class App {
// Insert code here
System.out.print("Welcome to the world of Java");
}
}
Which two code fragments, when inserted independently at line // Insert code here, enable the
program to execute and print the welcome message on the screen?
A. static public void main (String[] args) {
B. static void main (String[] args) {
C. public static void Main (String[] args) {
La respuesta A es CORRECTA.
La respuesta D es CORRECTA.
129 Given:
public class TestField {
int x;
int y;
B. 100 0 : 100 0 :
130 Given:
public static void main(String[] args) {
String ta = "A ";
ta = ta.concat("B ");
String tb = "C ";
ta = ta.concat(tb);
ta.replace('C', 'D');
ta = ta.concat(tb);
System.out.println(ta);
}
A. ABCD
B. ACD
C. ABC
D. ABD
E. ABDC
F. ABCC
La respuesta E es CORRECTA.
Which three code fragments can be independently inserted at line nl to enable the code to print
one?
A. Byte x = 1;
B. short x = 1;
C. String x = "1";
D. Long x = 1;
E. Double x = 1;
F. Integer x = new Integer("1");
La respuesta A es CORRECTA.
La respuesta B es CORRECTA.
La respuesta F es CORRECTA.
142 Given:
class Vehicle {
String trans;
4W 150 Manual
B. null 0 Auto
4W 150 Manual
La respuesta E es CORRECTA.
143 Given
public static void main(String[] args){
ArrayList<String> list = new ArrayList<>();
list.add("SE");
list.add("EE");
list.add("ME");
list.add("SE");
list.add("EE");
list.remove("SE");
144 Given:
import java.util.ArrayList;
import java.util.List;
La respuesta B es CORRECTA.
La respuesta A es CORRECTA.
switch (color) {
case "Red":
System.out.println("Found Red");
case "Blue":
System.out.println("Found Blue");
break;
case "Teal":
System.out.println("Found Teal");
break;
default:
System.out.println("Found Default");
}
A. Found Red
Found Default
B. Found Teal
C. Found Red
Found Blue
Found Teal
D. Found Red
Found Blue
Found Teal
Found Default
E. Found Default
La respuesta E es CORRECTA.
147 Given:
public class FieldInit {
char c;
boolean b;
float f;
void printAll() {
System.out.println("c = " + c);
System.out.println("c = " + b);
System.out.println("c = " + f);
}
B. c = 0
b = false
f = 0.0f
C. c = null
b = true
f = 0.0
D. c =
b = false
f = 0.0
La respuesta D es la CORRECTA.
A. ABC
B. ABCDE
C. ABDE
D. Compilation fails
La respuesta C es CORRECTA,
149
Which two are Java Exception classes?
A. SecurityException
B. DuplicatePathException
C. IllegalArgumentException
D. TooManyArgumentsException
La respuesta A es CORRECTA.
La respuesta C es CORRECTA.
150 Given:
class Alpha {
int ns;
static int s;
Alpha(int ns) {
if (s < ns) {
s = ns;
this.ns = ns;
}
}
void doPrint() {
System.out.println("ns = " + ns + " s = " + s);
}
}
B. ns = 50 s = 125
ns = 125 s = 125
ns = 0 s = 125
C. ns = 50 s = 50
ns = 125 s = 125
ns = 100 s = 100
D. ns = 50 s = 50
ns = 125 s = 125
ns = 0 s = 125
La respuesta B es CORRECTA.