Beruflich Dokumente
Kultur Dokumente
tools [l]
Sites [w]
Question 1 of 20
5.0/ 5.0 Points
class M {
public static void main (String[] args) {
StringBuffer sb1 = new StringBuffer("ABC");
StringBuffer sb2 = new StringBuffer("ABC");
System.out.print((sb1==sb2)+","+sb1.equals(sb2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 2 of 20
5.0/ 5.0 Points
class M {
public static void main(String[] s) {
String s1 = new String("ABCDEFG"), s2 = new String("EFGHIJ");
String s3 = s1.substring(4,7), s4 = s2.substring(0,3);
System.out.println((s3 == s4) + "," + (s3 + s4).equals(s4 + s3));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 3 of 20
5.0/ 5.0 Points
• Entries are organized as key/value pairs.
• Duplicate entries replace old entries.
Which interface of the java.util package offers the specified behavior?
A. List
B. Map
C. Set
Question 4 of 20
5.0/ 5.0 Points
class M {
public static void main(String[] args) {
String s1 = "A", s2 = "a", s3 = "b";
s1.toLowerCase(); s3.replace('b','a');
System.out.print((s1.equals(s2)) + "," + (s2.equals(s3)));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 5 of 20
0.0/ 5.0 Points
class A {
public static void main (String args[]) {
Integer i1 = new Integer(1);
Integer i2 = new Integer(i1);
System.out.print(i1.equals(i2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false
B. Prints: true
C. Compile-time error
D. Run-time error
Question 6 of 20
0.0/ 5.0 Points
class A {
public static void main (String args[]) {
Double d1 = new Double(1.0);
Double d2 = new Double(d1);
System.out.print(d1.equals(d2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false
B. Prints: true
C. Compile-time error
D. Run-time error
Question 7 of 20
5.0/ 5.0 Points
• Entries are organized as key/value pairs.
• Duplicate entries replace old entries.
• Entries are sorted using a Comparator or the Comparable interface.
Which interface of the java.util package offers the specified behavior?
A. List
B. Map
C. Set
D. SortedSet
E. SortedMap
Question 8 of 20
5.0/ 5.0 Points
Which implementation of the List interface provides for the fastest insertion of a new element
into the middle of the list?
A. Vector
B. ArrayList
C. LinkedList
Question 9 of 20
5.0/ 5.0 Points
class M {
static void m1(StringBuffer s1) {
s1 = s1.append("B"); System.out.print(s1);
}
static void m2(StringBuffer s1) {
s1.append("C"); System.out.print(s1);
}
public static void main(String[] s) {
StringBuffer s1 = new StringBuffer("A");
m1(s1); m2(s1);
System.out.print(s1);
}
}
What is the result of attempting to compile and run the program?
A. Prints: AAA
B. Prints: ABAA
C. Prints: ABACA
D. Prints: ABABAB
E. Prints: ABABCAB
F. Prints: ABABCABC
G. Prints: ABCABCABC
H. Compile-time error
I. Run-time error
Question 10 of 20
5.0/ 5.0 Points
• Entries are not organized as key/value pairs.
• Duplicate entries are rejected.
Which interface of the java.util package offers the specified behavior?
A. List
B. Map
C. Set
Question 11 of 20
0.0/ 5.0 Points
• Each element must be unique.
• Contains no duplicate elements.
• Elements are not key/value pairs.
• Accessing an element can be almost as fast as performing a similar operation on an array.
Which of these classes provides the specified features?
A. LinkedList
B. TreeMap
C. TreeSet
D. HashMap
E. HashSet
F. LinkedHashMap
G. Hashtable
Question 12 of 20
5.0/ 5.0 Points
class B {
public static void main (String[] args) {
byte b1 = 11;
System.out.print(new Integer(b1).equals(new Integer(b1)) + ",");
System.out.print(new Integer(b1).equals(new Short(b1)) + ",");
System.out.print(new Integer(b1).equals(new Byte(b1)));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false,false
B. Prints: false,false,true
C. Prints: false,true,false
D. Prints: false,true,true
E. Prints: true,false,false
F. Prints: true,false,true
G. Prints: true,true,false
H. Compile-time error
I. Run-time error
Question 13 of 20
5.0/ 5.0 Points
class E {
public static void main (String[] args) {
Byte b1 = new Byte("1"), b2 = new Byte("1");
System.out.print((b1==b2)+","+(b1.equals(b2)));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 14 of 20
5.0/ 5.0 Points
class ColorException extends Exception {}
class WhiteException extends ColorException {}
class White {
void m1() throws ColorException {throw new WhiteException();}
void m2() throws WhiteException {}
public static void main (String[] args) {
White white = new White();
int a,b,d,f; a = b = d = f = 0;
try {white.m1(); a++;} catch (ColorException e) {b++;}
try {white.m2(); d++;} catch (WhiteException e) {f++;}
System.out.print(a+","+b+","+d+","+f);
}
}
What is the result of attempting to compile and run the program?
A. Prints: 0,1,0,0
B. Prints: 1,1,0,0
C. Prints: 0,1,1,0
D. Prints: 1,1,1,0
E. Prints: 1,1,1,1
F. Compile-time error
G. Run-time error
Question 15 of 20
5.0/ 5.0 Points
class B {
public static void main (String args[]) {
Byte b1 = new Byte(1); // 1
Byte b2 = new Byte('2'); // 2
Byte b3 = new Byte("3"); // 3
byte i1 = b1.byteValue()+b2.byteValue()+b3.byteValue(); // 4
System.out.print(i1);
}
}
What is the result of attempting to compile and run the program? (Multi choice)
A. Run-time error
B. Compile-time error at 1
C. Compile-time error at 2
D. Prints: 6
E. Compile-time error at 3
F. Compile-time error at 4
Question 16 of 20
0.0/ 5.0 Points
class B {
public static void main (String args[]) {
Long i1 = new Long(1);
Long i2 = new Long(i1);
System.out.print((i1==i2) + "," + i1.equals(i2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
G. None of the above
Question 17 of 20
5.0/ 5.0 Points
class M {
public static void main (String[] args) {
String s1 = "ABC";
StringBuffer s2 = new StringBuffer(s1);
System.out.print(s2.equals(s1) + "," + s1.equals(s2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 18 of 20
5.0/ 5.0 Points
• Stores key/value pairs.
• Duplicate entries replace old entries.
• Entries are sorted using a Comparator or the Comparable interface.
Which of these classes provides the specified features?
A. LinkedList
B. TreeMap
C. TreeSet
D. HashMap
E. HashSet
F. Hashtable
G. None of the above
Question 19 of 20
5.0/ 5.0 Points
class D {
public static void main (String[] args) {
Boolean b1 = new Boolean("trUE"); // 1
Boolean b2 = new Boolean("What's This?"); // 2
Boolean b3 = new Boolean(null); // 3
System.out.print(b1 + "," + b2 + "," + b3);
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false,false
B. Prints: false,false,true
C. Prints: false,true,false
D. Prints: false,true,true
E. Prints: true,false,false
F. Prints: true,false,true
G. Prints: true,true,false
H. Prints: true,true,true
I. Compile-time error
J. Run-time error
Question 20 of 20
5.0/ 5.0 Points
class A {
public static void main(String[] args) {
Boolean b1 = new Boolean(true); // 1
Boolean b2 = new Boolean(false); // 2
Boolean b3 = new Boolean(TRUE); // 3
Boolean b4 = new Boolean(FALSE); // 4
Boolean b5 = new Boolean("TrUe"); // 5
Boolean b6 = new Boolean("fAlSe"); // 6
}
}
Compile-time errors are generated at which lines? (Multi choice)
A. 3
B. 4
C. 1
D. 6
E. 5
F. 2
NHẤT
HCMUAF_ICT14_JAVA_05_BTJB_Quiz3_Exception
Handling & Utility Classes
Return to Assessment List
Question 1 of 20
5.0/ 5.0 Points
class B {
public static void main (String[] args) {
byte b1 = 11;
System.out.print(new Integer(b1).equals(new Integer(b1)) + ",");
System.out.print(new Integer(b1).equals(new Short(b1)) + ",");
System.out.print(new Integer(b1).equals(new Byte(b1)));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false,false
B. Prints: false,false,true
C. Prints: false,true,false
D. Prints: false,true,true
E. Prints: true,false,false
F. Prints: true,false,true
G. Prints: true,true,false
H. Compile-time error
I. Run-time error
Question 2 of 20
5.0/ 5.0 Points
class G {
public static void main (String[] args) {
Integer i1 = new Integer("1"), i2 = new Integer("1");
StringBuffer sb1 = new StringBuffer("1");
StringBuffer sb2 = new StringBuffer("1");
System.out.print(sb1.equals(sb2)+","+i1.equals(i2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 3 of 20
5.0/ 5.0 Points
class A {
public static void main (String args[]) {
Integer i1 = new Integer(1);
Integer i2 = new Integer(i1);
System.out.print(i1.equals(i2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false
B. Prints: true
C. Compile-time error
D. Run-time error
Question 4 of 20
5.0/ 5.0 Points
class M {
public static void main (String[] args) {
StringBuffer sb1 = new StringBuffer("ABC");
StringBuffer sb2 = new StringBuffer("ABC");
System.out.print((sb1==sb2)+","+sb1.equals(sb2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 5 of 20
5.0/ 5.0 Points
class E {
public static void main (String[] args) {
Byte b1 = new Byte("1"), b2 = new Byte("1");
System.out.print((b1==b2)+","+(b1.equals(b2)));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 6 of 20
5.0/ 5.0 Points
class A {
public static void main (String[] args) {
Error error = new Error();
Exception exception = new Exception();
System.out.print((exception instanceof Throwable) + ",");
System.out.print(error instanceof Throwable);
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 7 of 20
5.0/ 5.0 Points
class M {
public static void main(String[] s) {
String s1 = "1", s2 = "2", s3 = s1 + s2;
s1 += s2; s3 += s1;
System.out.println(s3);
}
}
What is the result of attempting to compile and run the program?
A. Prints: 3
B. Prints: 6
C. Prints: 33
D. Prints: 1212
E. Compile-time error
F. Run-time error
Question 8 of 20
0.0/ 5.0 Points
class M {
static void m1(StringBuffer s1) {
s1.append("B"); System.out.print(s1);
}
static void m2(StringBuffer s1) {
s1 = new StringBuffer("C"); System.out.print(s1);
}
public static void main(String[] s) {
StringBuffer s1 = new StringBuffer("A");
m1(s1); m2(s1);
System.out.print(s1);
}
}
What is the result of attempting to compile and run the program?
A. Prints: AAA
B. Prints: ABCA
C. Prints: ABCAB
D. Prints: ABCABC
E. Prints: ABCAC
F. Prints: ABABCABC
G. Compile-time error
H. Run-time error
Question 9 of 20
5.0/ 5.0 Points
Which implementation of the List interface produces the slowest access to an element in the
middle of the list by means of an index?
A. Vector
C. ArrayList
D. LinkedList
Question 10 of 20
5.0/ 5.0 Points
class B {
public static void main (String args[]) {
Long i1 = new Long(1);
Long i2 = new Long(i1);
System.out.print((i1==i2) + "," + i1.equals(i2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 11 of 20
5.0/ 5.0 Points
class D {
public static void main (String[] args) {
Boolean b1 = new Boolean("trUE"); // 1
Boolean b2 = new Boolean("What's This?"); // 2
Boolean b3 = new Boolean(null); // 3
System.out.print(b1 + "," + b2 + "," + b3);
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false,false
B. Prints: false,false,true
C. Prints: false,true,false
D. Prints: false,true,true
E. Prints: true,false,false
F. Prints: true,false,true
G. Prints: true,true,false
H. Prints: true,true,true
I. Compile-time error
J. Run-time error
A. Prints: ABC
B. Prints: A B C
C. Prints: ABCD
D. Prints: ABDC
E. Prints: A B CD
F. Prints: A B DC
G. Compile-time error
H. Run-time error
Question 13 of 20
5.0/ 5.0 Points
class B {
public static void main (String args[]) {
Long i1 = new Long(1);
Long i2 = new Long(i1);
System.out.print((i1==i2) + "," + i1.equals(i2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 14 of 20
5.0/ 5.0 Points
• Entries are organized as key/value pairs.
• Duplicate entries replace old entries.
Which interface of the java.util package offers the specified behavior?
A. List
B. Map
C. Set
Question 15 of 20
5.0/ 5.0 Points
class M {
static void m1(StringBuffer s1) {
s1 = s1.append("B"); System.out.print(s1);
}
static void m2(StringBuffer s1) {
s1.append("C"); System.out.print(s1);
}
public static void main(String[] s) {
StringBuffer s1 = new StringBuffer("A");
m1(s1); m2(s1);
System.out.print(s1);
}
}
What is the result of attempting to compile and run the program?
A. Prints: AAA
B. Prints: ABAA
C. Prints: ABACA
D. Prints: ABABAB
E. Prints: ABABCAB
F. Prints: ABABCABC
G. Prints: ABCABCABC
H. Compile-time error
I. Run-time error
Question 16 of 20
5.0/ 5.0 Points
class A {
public static void main (String args[]) {
Double d1 = new Double(1.0);
Double d2 = new Double(d1);
System.out.print(d1.equals(d2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false
B. Prints: true
C. Compile-time error
D. Run-time error
Question 17 of 20
5.0/ 5.0 Points
class B {
public static void main (String args[]) {
Byte b1 = new Byte(1); // 1
Byte b2 = new Byte('2'); // 2
Byte b3 = new Byte("3"); // 3
byte i1 = b1.byteValue()+b2.byteValue()+b3.byteValue(); // 4
System.out.print(i1);
}
}
What is the result of attempting to compile and run the program? (Multi choice)
A. Compile-time error at 4
B. Prints: 6
C. Compile-time error at 3
D. Compile-time error at 1
E. Compile-time error at 2
F. Run-time error
Question 18 of 20
5.0/ 5.0 Points
class M {
public static void main (String[] args) {
String s1 = "ABC";
StringBuffer s2 = new StringBuffer(s1);
System.out.print(s2.equals(s1) + "," + s1.equals(s2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 19 of 20
0.0/ 5.0 Points
• Stores key/value pairs.
• Allows null elements, keys, and values.
• Duplicate entries replace old entries.
• Entries are not sorted.
Which of these classes provides the specified features?
A. LinkedList
B. TreeMap
C. TreeSet
D. HashMap
E. HashSet
F. Hashtable
Question 20 of 20
5.0/ 5.0 Points
class M {
public static void main(String[] s) {
String s1 = new String("ABCDEFG"), s2 = new String("EFGHIJ");
String s3 = s1.substring(4,7), s4 = s2.substring(0,3);
System.out.println((s3 == s4) + "," + (s3 + s4).equals(s4 + s3));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Trung
HCMUAF_ICT14_JAVA_05_BTJB_Quiz3_Exception
Handling & Utility Classes
Return to Assessment List
Question 1 of 20
0.0/ 5.0 Points
class A {
public static void main (String args[]) {
Double d1 = new Double(1.0);
Double d2 = new Double(d1);
System.out.print(d1.equals(d2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false
B. Prints: true
C. Compile-time error
D. Run-time error
Question 2 of 20
5.0/ 5.0 Points
• Each element must be unique.
• Contains no duplicate elements.
• Elements are not key/value pairs.
• Accessing an element can be almost as fast as performing a similar operation on an array.
Which of these classes provides the specified features?
A. LinkedList
B. TreeMap
C. TreeSet
D. HashMap
E. HashSet
F. LinkedHashMap
G. Hashtable
Question 3 of 20
5.0/ 5.0 Points
class ColorException extends Exception {}
class WhiteException extends ColorException {}
class White {
void m1() throws ColorException {throw new WhiteException();}
void m2() throws WhiteException {}
public static void main (String[] args) {
White white = new White();
int a,b,d,f; a = b = d = f = 0;
try {white.m1(); a++;} catch (ColorException e) {b++;}
try {white.m2(); d++;} catch (WhiteException e) {f++;}
System.out.print(a+","+b+","+d+","+f);
}
}
What is the result of attempting to compile and run the program?
A. Prints: 0,1,0,0
B. Prints: 1,1,0,0
C. Prints: 0,1,1,0
D. Prints: 1,1,1,0
E. Prints: 1,1,1,1
F. Compile-time error
G. Run-time error
H. None of the above
Question 4 of 20
5.0/ 5.0 Points
class D {
public static void main (String[] args) {
Boolean b1 = new Boolean("trUE"); // 1
Boolean b2 = new Boolean("What's This?"); // 2
Boolean b3 = new Boolean(null); // 3
System.out.print(b1 + "," + b2 + "," + b3);
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false,false
B. Prints: false,false,true
C. Prints: false,true,false
D. Prints: false,true,true
E. Prints: true,false,false
F. Prints: true,false,true
G. Prints: true,true,false
H. Prints: true,true,true
I. Compile-time error
J. Run-time error
Question 5 of 20
5.0/ 5.0 Points
class A {
public static void main (String args[]) {
Integer i1 = new Integer(1);
Integer i2 = new Integer(i1);
System.out.print(i1.equals(i2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false
B. Prints: true
C. Compile-time error
D. Run-time error
Question 6 of 20
5.0/ 5.0 Points
class B {
public static void main (String args[]) {
Long i1 = new Long(1);
Long i2 = new Long(i1);
System.out.print((i1==i2) + "," + i1.equals(i2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 7 of 20
5.0/ 5.0 Points
class B {
public static void main (String[] args) {
byte b1 = 11;
System.out.print(new Integer(b1).equals(new Integer(b1)) + ",");
System.out.print(new Integer(b1).equals(new Short(b1)) + ",");
System.out.print(new Integer(b1).equals(new Byte(b1)));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false,false
B. Prints: false,false,true
C. Prints: false,true,false
D. Prints: false,true,true
E. Prints: true,false,false
F. Prints: true,false,true
G. Prints: true,true,false
H. Compile-time error
I. Run-time error
Question 8 of 20
5.0/ 5.0 Points
class B {
public static void main (String args[]) {
Long i1 = new Long(1);
Long i2 = new Long(i1);
System.out.print((i1==i2) + "," + i1.equals(i2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 9 of 20
0.0/ 5.0 Points
• Stores key/value pairs.
• Duplicate entries replace old entries.
• Entries are sorted using a Comparator or the Comparable interface.
Which of these classes provides the specified features?
A. LinkedList
B. TreeMap
C. TreeSet
D. HashMap
E. HashSet
F. Hashtable
Question 10 of 20
5.0/ 5.0 Points
class A {
public static void main(String[] args) {
Boolean b1 = new Boolean(true); // 1
Boolean b2 = new Boolean(false); // 2
Boolean b3 = new Boolean(TRUE); // 3
Boolean b4 = new Boolean(FALSE); // 4
Boolean b5 = new Boolean("TrUe"); // 5
Boolean b6 = new Boolean("fAlSe"); // 6
}
}
Compile-time errors are generated at which lines? (Multi choice)
A. 1
B. 3
C. 6
D. 2
E. 4
F. 5
Question 11 of 20
5.0/ 5.0 Points
class M {
public static void main (String[] args) {
StringBuffer sb1 = new StringBuffer("ABC");
StringBuffer sb2 = new StringBuffer("ABC");
System.out.print((sb1==sb2)+","+sb1.equals(sb2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 12 of 20
5.0/ 5.0 Points
class M {
public static void main(String[] s) {
String s1 = "A", s2 = " B ", s3 = "C";
s2.trim(); s3.concat("D");
System.out.print(s1 + s2 + s3);
}
}
What is the result of attempting to compile and run the program?
A. Prints: ABC
B. Prints: A B C
C. Prints: ABCD
D. Prints: ABDC
E. Prints: A B CD
F. Prints: A B DC
G. Compile-time error
H. Run-time error
Question 13 of 20
5.0/ 5.0 Points
class M {
public static void main(String[] args) {
String s1 = "A", s2 = "a", s3 = "b";
s1.toLowerCase(); s3.replace('b','a');
System.out.print((s1.equals(s2)) + "," + (s2.equals(s3)));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 14 of 20
5.0/ 5.0 Points
• Stores key/value pairs.
• Allows null elements, keys, and values.
• Duplicate entries replace old entries.
• Entries are not sorted.
Which of these classes provides the specified features?
A. LinkedList
B. TreeMap
C. TreeSet
D. HashMap
E. HashSet
F. Hashtable
Question 15 of 20
5.0/ 5.0 Points
class A {
public static void main (String[] args) {
Error error = new Error();
Exception exception = new Exception();
System.out.print((exception instanceof Throwable) + ",");
System.out.print(error instanceof Throwable);
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 16 of 20
5.0/ 5.0 Points
class G {
public static void main (String[] args) {
Integer i1 = new Integer("1"), i2 = new Integer("1");
StringBuffer sb1 = new StringBuffer("1");
StringBuffer sb2 = new StringBuffer("1");
System.out.print(sb1.equals(sb2)+","+i1.equals(i2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 17 of 20
5.0/ 5.0 Points
class M {
public static void main(String[] s) {
String s1 = new String("ABCDEFG"), s2 = new String("EFGHIJ");
String s3 = s1.substring(4,7), s4 = s2.substring(0,3);
System.out.println((s3 == s4) + "," + (s3 + s4).equals(s4 + s3));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 18 of 20
5.0/ 5.0 Points
Which implementation of the List interface produces the slowest access to an element in the
middle of the list by means of an index?
A. ArrayList
B. LinkedList
C. Vector
Question 19 of 20
5.0/ 5.0 Points
class M {
public static void main (String[] args) {
String s1 = "ABC";
StringBuffer s2 = new StringBuffer(s1);
System.out.print(s2.equals(s1) + "," + s1.equals(s2));
}
}
What is the result of attempting to compile and run the program?
A. Prints: false,false
B. Prints: false,true
C. Prints: true,false
D. Prints: true,true
E. Compile-time error
F. Run-time error
Question 20 of 20
5.0/ 5.0 Points
class M {
public static void main(String[] s) {
String s1 = "1", s2 = "2", s3 = s1 + s2;
s1 += s2; s3 += s1;
System.out.println(s3);
}
}
What is the result of attempting to compile and run the program?
A. Prints: 3
B. Prints: 6
C. Prints: 33
D. Prints: 1212
E. Compile-time error
F. Run-time error