public class ReturnIt { returnType methodA(byte x, double y) /* Line 3 */ { return (long)x / y * 2; } }
Java's widening conversions are:
- From a byte to a short, an int, a long, a float, or a double.
- From a short, an int, a long, a float, or a double.
- From a char to an int, a long, a float, or a double.
- From an int to a long, a float, or a double.
- From a long to a float, or a double.
- From a float to a double.
Option B is incorrect. It generates a compiler error: incompatible types because the array variable declaration is not correct. The array construction expects a reference type, but it is supplied with a primitive type in the declaration.
Option C is incorrect. It generates a compiler error: incompatible types because a string literal is not assignable to a character type variable.
Option D is wrong, it generates a compiler error <identifier> expected. The compiler thinks that you are trying to create two arrays because there are two array initialisers to the right of the equals, whereas your intention was to create a 3 x 3 two-dimensional array.
Option A is wrong. A map is an object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value. The Map interface provides three collection views, which allow a map's contents to be viewed as a set of keys, collection of values, or set of key-value mappings. The order of a map is defined as the order in which the iterators on the map's collection views return their elements. Some map implementations, like the TreeMap class, make specific guarantees as to their order (ascending key order); others, like the HashMap class, do not (does not guarantee that the order will remain constant over time).
Option C is wrong. A list is an ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list. Unlike sets, lists typically allow duplicate elements.
Option D is wrong. A collection is also known as a sequence. The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list. Unlike sets, lists typically allow duplicate elements.
When a new LinkedHashMap is created by passing a reference to an existing Collection to the constructor of a LinkedHashMap the Collection.addAll method will ultimately be invoked.
The addAll method uses an iterator to the existing Collection to iterate through the elements of the existing Collection and add each to the instance of the new LinkedHashMap.
Since the iteration order of the LinkedHashMap is determined by the order of insertion, the iteration order of the new LinkedHashMap must be the same as the interation order of the old Collection.
/* Missing Statement? */ public class foo { public static void main(String[]args)throws Exception { java.io.PrintWriter out = new java.io.PrintWriter(); new java.io.OutputStreamWriter(System.out,true); out.println("Hello"); } }
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.