Analyze the following code.

```
public class Test {
public static void main(String[] args) {
java.util.Date x = new java.util.Date();
java.util.Date y = x.clone();
System.out.println(x = y);
}
}```
a. A java.util.Date object is not cloneable.
b. x = y in System.out.println(x = y) causes a compile error because you cannot have an assignment statement inside a statement.
c. x = y in System.out.println(x = y) causes a runtime error because you cannot have an assignment statement inside a statement.
d. The program has a compile error because the return type of the clone() method is java.lang.Object.


d (A) is wrong because Date implements and Cloneable and overrides the clone() method. (B) and (C) are wrong because x = y is an assignment expression, which assigns y to x. (D) is correct. You have to cast it into Date in order to assign it to y.

Computer Science & Information Technology

You might also like to view...

Which of the following is the default line spacing in Microsoft Word 2010?

A) 1.25 B) 1.15 C) 1.0 D) 2.0

Computer Science & Information Technology

While attending a security conference you notice that almost all attendees are using smartphones with only a very small number using laptops. Which of the following is the biggest security issue with the conference?

A. physical theft of smartphones B. open Ethernet jacks C. physical theft of laptops D. bluejacking attacks

Computer Science & Information Technology

Name and briefly describe eight of the fourteen properties that can be set in the Table Properties dialog box.

What will be an ideal response?

Computer Science & Information Technology

1. Which of the following is not a way of packaging code?

a) methods b) classes c) variables d) namespaces

Computer Science & Information Technology