double pi = Math.PI;Which two are valid ways to round pi to an int?(Choose two.)

A.int p = pi;

B.int p = Math.round(pi);

C.int p = (int)Math.round(pi);

D.int p = (int)Math.min(pi + 0.5d);

E.int p = (int)Math.floor(pi + 0.5d);

8. Which two statements are true for the class java.util.TreeSet? (Choose two.)

A.The elements in the collection are ordered.

B.The collection is guaranteed to be immutable.

C.The elements in the collection are guaranteed to be unique.

D.The elements in the collection are accessed using a unique key.

E.The elements in the collection are guaranteed to be synchronized

(No Answers for this Test)

Answers # 3

1.prints Color=Blue

Because Object Class is Super Class of Every Class therefore, String array object can be assigned to Object array.For example ,

class Super{}

class Derived extends Super{}

class Test{

public static void main(String []argv)

{

Supersupobj = new Derived();

}

}

2.C&E

private class InnerOne

{
double methoda()

{

return d1;

}
}

And,

abstract class InnerOne

{
public abstract double methoda();
}

other options are false because a non-static inner class cannot have static context i.e for options A and B. for D it is false because the variable cannot be referenced from static context, because of static inner class.

3. D just after line 6 (that is, as the method returns)

Because the Object x has local scope i.e it is in the method therefore it will be garbage

Collected after method returns to caller.

4. C_object

options A is boolean literal and B is keywords for Java where as – (miuns) is not allowed as identifier for object or variablebane. So C is correct.