Worksheetsjava 10
Total questions: 6
Worksheet time: 4mins
Name
Class
Date
1.
What will be the output?
var name = "Mike";
System.out.println("Mike".equals(name));
a)
"true"
b)
"false"
c)
compile time error
d)
run time exception
2.
What is the issue with below code?
public static var createVar(var a)
{
return a;
}
a)
No issues, it will work fine
b)
we can't have var as return type
c)
we can't have var as arguments
d)
Both B&C
3.
What is output of the below program?
Set<Integer> integerset = Set.of(1,2,3,4,5);
Set<Integer> copySet = Set.copyOf( integers.stream().collect(Collectors.toSet()));
copySet.add(4);
a)
java.lang.UnsupportedOperationException
b)
No Exception is thrown as we already have 4 in the set
c)
compile time error as Set doesn’t have copyOf Method
d)
Set will have a new element 1,2,3,4,5,4
4.
What is output of the below program?<br />List<Integer> someIntList3 = Arrays.asList(1,3,5);
someIntList3.stream().filter(i -> i % 2 == 0).orElseThrow();
a)
NoSuchElementException
b)
compile time error as orElseThrow is not a method of Stream
c)
Creates a Integer list with No Elements
d)
None of the Above
5.
What are the primary motivation for App CDS?
a)
Reduced Footprints
b)
Reduced Startup Time
c)
Loading default set of classes
d)
Data replication on each JVM
6.
What were the issue before Container Awareness provided in java 10?
a)
problems with memory and cpu sizing and usage that led to performance loss
b)
Docker container users to gain more fine-grained control over the amount of system memory
c)
Java didn’t recognize that it was running in a container
d)
None of the Above
100 %
