Examen Java Programmer I OCA JP
Examen Java Programmer I OCA JP
Examen Java Programmer I OCA JP
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
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;
private int getNum() {
return num;
}
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.
3 Given:
public class Whizlabs {
public static void main(String[] args) {
String s = "A";
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.
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());
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++;
}
A. 2 4
B. 0 2 4 6
C. 0 2 4
D. Compilation fails
7 Given:
A. null
B. Compilation fails
D. 0
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.
C.
System.out.print(LocalTime.now());
D.
System.out.print(LocalTime.today());
10 Given:
javac Test.Java
A. Success
B. Failure
C. Compilation fails.
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
12 Given:
int i, j = 0;
i = (3 * 2 + 4 + 5);
j = (3 * ((2 + 4) + 5));
System.out.println("i:" + i + "\nj:" + j);
i:16
j:33
B.
i.15
j:33
C.
i:33
j:23
D.
i:15
j:23
A.
1.0, 1
B.
1.0f, 1
C.
7.33, 7
D. Compilation fails
15 Given:
public class Equal {
A.
true, false
B.
false, true
C.
true, true
D.
false, false
16 Given:
B.
C.
11
D.
10
E. Compilation fails
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
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.
C.
D.
Student(int i, String name, ArrayList cs) {
/* initialization code goes here */
}
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?
20 Given :
A.
B.
3
C.
D. Compilation fails
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());
Which two statements, when inserted independently at line // insert code here, enable the code
to compile?
A.
int[][] arr = null;
B.
int[][] arr = new int[2];
C.
int[][] arr = new int[2][];
D.
F.
int[][] arr = new int[0][4];
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.
B.
int e = 0; e < 5; e += 2
C.
int e = 1; e <= 5; e += 1
D.
int e = 1; e < 5; e +=2
25 Given:
public class X implements Z {
class Y extends X {
interface Z {
A.
XXX
B.
XYX
C.
YYX
D.
YYY
26 Given:
public class ComputeSum {
public int x;
public int y;
public int sum;
void updateSum() {
sum = x + y;
}
}
This class needs to protect an invariant on the sum field.
Which three members must have the private access modifier to ensure that this invariant is
maintained?
A. The x field
B. The y field
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.
28 Given:
A.
120
B.
120D
C. It can be overloaded.
D. The default constructor of a subclass always invokes the no-argument constructor of its
superclass.
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.
A.
28false29
true
B.
C.
true
true
D. compilation fails
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)
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
34 Given:
javac Palindrome.java
A. Compilation fails
C.
Paildrome
D.
Wow
E.
Mom
35 Given:
public class Access {
private int x = 0;
private int y = 0;
A.
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
A. Line 5
B. Line 7
C. Line 8
D. Line 9
E. Line 10
F. Line 11
37 Given:
int num;
B. 2
C. 3
D. 4
A.java
public class A {
B.java
public class B {
C.java
import java.io.*;
package p1;
class C {
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; }
40 Given the code fragments:
Person.java
public class Person {
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.
011
B.
012
C.
123
D.
000
42 Given:
MainTest.java
public class MainTest {
and commands:
javac MainTest.java
java MainTest 1 2 3
What is the result?
A.
int main 1
B.
Object main 1
C.
String main 1
D. Compilation fails
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.
44 Given the code fragment:
String[] cartoons = {"tom", "jerry", "micky", "tom"};
int counter = 0;
if ("tom".equals(cartoons[0])) {
counter++;
} else if ("tom".equals(cartoons[1])) {
counter++;
} else if ("tom".equals(cartoons[2])) {
counter++;
} else if ("tom".equals(cartoons[3])) {
counter++;
}
System.out.print(counter);
A.
B.
C.
D.
A.
Student student1;
B.
Student student1 = Student.new();
C.
Student student1 = new Student();
D.
Student student1 = Student();
}
}
47 Given:
A.
: Fresco
B.
null : Fresco
C.
Fresco : Fresco
48 Given:
class Dog {
Dog() {
try {
throw new Exception();
} catch (Exception e) { }
}
}
class Test {
A. Two
B. Three
C. Four
D. Six
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(p1.show());
System.out.println(p2.show());
}
A.
Jesse 25
Walter 52
51 Given:
DoInterface.java
package p1;
Test.java
package p3;
import p1.DoInterface;
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.
D. Every class that is a subclass of RuntimeException and Error is categorized as checked
exception.
E. Every class that is a subclass of Exception, excluding RuntimeException and its subclasses, is
categorized as checked exception.
53 Given:
A. Found 3 at 2
B. Found 3 at 3
C. Compilation fails
A.
Match 1
B.
Match 2
C.
No Match
Which two code fragments, independently, print each element in this array?
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] + " ");
}
56 Which of the following can fill in the blank in this code to make it
compile? (Select 2 options.)
interface Contract {
}
objs.add(c1);
objs.add(c2);
objs.add(s1); // line n2
A.
Super
Sub
Sub
B.
Contract
Contract
Super
A.
1:2:3:4:5:
B.
1:2:3:
C. Compilation fails.
class Candidate {
String name;
int age;
James age: 20
Williams age: 32
A.
B.
C.
D.
60 Given:
A.
box
B.
nbo
C.
bo
D.
nb
B.
[Robb, Rick]
C.
A.
-6
B.
-4
C.
-5
D.
E.
F. Compilation fails
A. Only I.
B. Only II.
E. ALL
64 Given the following main method:
A.
543210
B.
54321
C.
421
D.
E. Nothing is printed
System.out.println(planets.length);
System.out.println(planets[1].length());
}
What is the output?
A.
B.
C.
D.
E.
F.
21
66 Which code fragment cause a compilation error?
A.
B.
C.
D.
double y1 = 203.22;
E.
int y2 = 100;
La respuesta D es CORRECTA.
67 Consider
sb.deleteAll();
B.
sb.delete(0, sb.size());
C.
sb.delete(0, sb.length());
D.
sb.removeAll();
A. NullPointerException
B. NegativeArraySizeException
C. ArrayIndexOutOfBoundsException
D. IndexOutOfBoundsException
70 Given:
Acc.java
package p1;
int p;
private int q;
protected int r;
public int s;
}
Test.java
package p2;
import p1.Acc;
71 Given:
A.
5:5
B.
6:4
C.
6:5
D.
5:4
72 Given:
A.
log3:false
log4:true
B.
log3:true
log4:true
C.
log3:true
log4:false
D.
log3:false
log4:false
73 Given the code fragment:
A. Line 21
B. Line 22
C. Line 23
D. Line 24
E. Line 25
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.
B.
C.
Either A or B
D.
AB
76 Given:
A.
B.
C.
D.
77 Given:
class Jump {
javac Jump.java
A.
B.
C.
D.
E. Compilation fails
79 Given:
package p1;
A.
p1.Test.class
0.0
0.000000
C.
null
0.0
D. Compilation fails
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
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())
82 Given:
class StaticField {
static int i = 7;
A.
10 10
B.
89
C.
98
D.
7 10
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
A.
B.
2014-05-04T00:00:00.000
C.
5/4/14T00:00:00.000
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.
System.out.println(planets);
System.out.println(planets[2]);
System.out.println(planets[2].moons);
}
A.
planets
Earth
1
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
87 Give:
Test.java
class Alpha {
javac Test.java
java Test 1 2
A.
1525
B.
13
C. Compilation fails
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;
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
C. Compilation fails.
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);
91 Given:
A.
123
B.
123xxx
C.
123456
D.
123456xxx
E. Compilation fails
92 Given:
public class ColorTest {
A.
Yellow
B.
Maroon
C. Compilation fails
A.
Area is 6.0
B.
Area is 3.0
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;
}
}
95 Given:
A.
true true
B.
true false
C.
false true
D.
false false
E. Compilation fails
A.
10 Hello World!
B.
Hello Universe!
C.
Hello World!
D. Compilation fails.
97 Given:
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();
E. None of above.
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();
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;
101 Given
public class Test {
public static void main(String[] args) {
Integer num = Integer.parseInt(args[1]);
System.out.println("Number is : " + num);
}
}
102 Given
public class Series {
A.
2 4 6 8 10 12
B.
2 4 6 8 10 12 14
C. Compilation fails
104 Given:
public class StringReplace {
A.
message = Hi everyone!
B.
message = Hi XvXryonX!
F.
message = Hi Xveryone!
105 Given:
public class TestScope {
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++;
}
A.
10 8 6 4 2 0
B.
10 8 6 4 2
E. Compilation fails
109 Given:
public static void main(String[] args) {
String theString = "Hello World";
System.out.println(theString.charAt(11));
}
B.
110 Given:
public class Whizlabs {
A.
2015-03-27
B.
2015-04-27
C.
2015-02-27
A.
20
B.
25
C.
29
D. Compilation fails
112 Given:
class Base {
A.
Base 30
B.
Overridden 20
C.
Overridden 20
Base 30
D.
Base 30
Overridden 20
113 Which three statements are true about the structure of a Java
class?
A. A class can have only one private constructor.
Which two modifications, made independently, enable the code to compile and run?
A.
13480.0
B.
13480.02
C. Compilation fails
116 Given:
public class App {
A.
10 : 22 : 20
B.
10 : 22 : 22
C.
10 : 22 : 6
D.
10 : 30 : 6
117 Given the code fragment:
public static void main(String[] args) { //line 1
int x = 5; //line 2
while (isAvailable(x)) { //line 3
System.out.print(x); //line 4
//line 5
} //line 6
} //line 7
//line 8
public static boolean isAvailable(int x) { //line 9
return x-- > 0 ? true : false; //line 10
} //line 11
118 Given:
class Caller {
Initialized
Started
B.
Initialized
Started
Initialized
C. Compilation fails
119 Given:
interface Readable {
// line n4
}
B. At line n2 insert:
D. At line n4 insert:
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
121 Given:
public class MarkList {
int num;
A. 1
B. 2
C. 3
D. 4
}
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;
}
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
124 Given:
class X {
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;
}
}
A.
100
B.
101
C.
102
D.
103
E. Compilation fails
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
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?
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
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");
142 Given:
class Vehicle {
String trans;
A. 4W 100 Auto
4W 150 Manual
B. null 0 Auto
4W 150 Manual
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;
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
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
A. ABC
B. ABCDE
C. ABDE
D. Compilation fails
149
Which two are Java Exception classes?
A. SecurityException
B. DuplicatePathException
C. IllegalArgumentException
D. TooManyArgumentsException
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