Which two statements are true for a two-dimensional array of primitive data type?
A.
It cannot contain elements of different types.
B.
The length of each dimension must be the same.
C.
At the declaration time, the number of elements of the array in each dimension must be
specified.
D.
All methods of the class object may be invoked on the two-dimensional array
At the declaration time, the number of elements of the array in each dimension must be
specified.
All methods of the class object may be invoked on the two-dimensional array
http://stackoverflow.com/questions/12806739/is-an-array-a-primitive-type-oran-
object-or-something-else-entirely
Given the code fragment:
List<String> listVal = Arrays.asList(“Joe”, “Paul”, “Alice”, “Tom”);
System.out.println (
// line n1
);
Which code fragment, when inserted at line n1, enables the code to print the count of string
elements whose length is greater than three?
A.
listVal.stream().filter(x -> x.length()>3).count()
B.
listVal.stream().map(x -> x.length()>3).count()
C.
listVal.stream().peek(x -> x.length()>3).count().get()
D.
listVal.stream().filter(x -> x.length()>3).mapToInt(x -> x).count()
listVal.stream().peek(x -> x.length()>3).count().get()
Given:
1. abstract class Shape {
2. Shape ( ) { System.out.println (“Shape”); }
3. protected void area ( ) { System.out.println (“Shape”); }
4. }
5.
6. class Square extends Shape {
7. int side;
8. Square int side {
9./* insert code here */
10. this.side = side;
11. }
12. public void area ( ) { System.out.println (“Square”); }
13. }
14. class Rectangle extends Square {
15. int len, br;
16. Rectangle (int x, int y) {
17. /* insert code here */
18. len = x, br = y;
19. }
20. void area ( ) { System.out.println (“Rectangle”); }
21. }
Which two modifications enable the code to compile?
A.
A. At line 1, remove abstract
B.
At line 9, insert super ( );
C.
At line 12, remove public
D.
At line 17, insert super (x);
E.
At line 17, insert super (); super.side = x;
F.
At line 20, use public void area ( ) {
At line 12, remove public
At line 17, insert super (x);
Which two are Java Exception classes?
A.
SercurityException
B.
DuplicatePathException
C.
DuplicatePathException
D.
IllegalArgumentException
E.
TooManyArgumentsException
SercurityException
DuplicatePathException
Given the code fragments:
class TechName {
String techName;
TechName (String techName) {
this.techName=techName;
}
}
and
List<TechName> tech = Arrays.asList (
new TechName(“Java-“),
new TechName(“Oracle DB-“),
new TechName(“J2EE-“)
);
Stream<TechName> stre = tech.stream();
//line n1
Which should be inserted at line n1 to print Java-Oracle DB-J2EE-?
A.
stre.forEach(System.out::print);
B.
stre.map(a-> a.techName).forEach(System.out::print);
C.
stre.map(a-> a).forEachOrdered(System.out::print);
D.
stre.forEachOrdered(System.out::print);
stre.map(a-> a).forEachOrdered(System.out::print);
Page 1 out of 26 Pages |