Java Innards

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

1) Which of these interfaces are functional interfaces?

public interface Cards{ int totalCount(int a, int b); }


2) Which of the following functional interface represents an operation upon two
long-valued operands and produces a long-valued result?
LongToLongFunction
3) A functional interface acts as target types for which of the following?
All the options mentioned
4) Which of the following functional interface represents a function that
accepts an int-valued argument and produces a long-valued result?
IntToLongFunction
5) Which of the following functional interface represents an operation that
accepts an object-valued and an int-valued argument, and returns no result?
ObjIntConsumer
6) Stream operation iterations are internal over the source of elements
False
7) Which of these does Stream filter() operates on
Preficate
8) Terminal operation produces another stream as its output
False
9) Each pipeline ends with a
Terminal Op
10) Which of the following is valid Stream operation type
Both
11) Repeating annotations can be retrieved using
getAnnotationsByType()
12) Optional type validation can be used to substitute runtime validations.
False
13) On which of these does annotations can be used on in Java 8
All the options mentioned
*14) On calling add() method as described below, String r = adderImpl.add(a -> a
+ " lambda"); System.out.println(r);
Prints "Welcome lambda"
15) Which of the following class implements an encoder for encoding byte data
using the Base64 encoding scheme in Java8?
Base64.Encoder
16) Identify intermediate and terminal operations in the code.
Intermediate: filter, mapToInt Terminal: getAsDouble
17) Method used to fetch the parameter types using method parameter reflection
getParameterizedType()
18) Below code includes a valid Functional Interface ?
True
*false 19) Which of the following are valid uses of lambda expressions?
All the options mentioned
20) Choose the correct output.
String value is not present
21) Reactive Programming deals with
asynchronous data
22) We need to override which Predicate method in Java 8. Which is the right
method call
test(T t)
23) Which package contains Date/Time (JSR 310) API in Java 8
java.time
24) In Functional Reactive Programming, we pull the stream of data
True
25) Library used to write reactive programs in java
RxJava
26) public class App{
public static void main(String [] args){
String name="WelcomeJava";
Runnable r1=() -> System.out.println(name);
String name1="";
name1=name.toUpperCase();
Runnable r2=() -> System.out.println(name1);
r1.run();

This study source was downloaded by 100000797727937 from CourseHero.com on 04-01-2023 06:49:17 GMT -05:00

https://www.coursehero.com/file/62000114/Java-Innardstxt/
}
}
What is the o/p of the above program?
Runtime error
27) Which class can be used Instead of System.getCurrentTimeMillis() to get a
date and time in Java 8
Clock
*28) Which methods preserve parameter names in Java bytecode (through reflection
API)
All public methods
29) PermGen space has been replaced with which of these in Java 8
Metaspace
30) Which method is used to connect the consumer to the source in reactive
programming
subscribe()
31) DateTimeFormatter dateFormat=DateTimeFormatter.ISO_DATE;
LocalDate dateOfBirth= LocalDate.of(2015,Month.FEBRUARY,31);
System.out.println(dateFormat.format(dateOfBirth));
Choose the correct option.
Java DateTimeException
32) Which is new command line tool for the Nashorn JavaScript engine in java 8
jjs
33) DateTimeFormatter formatter=DateTimeFormatter.ofPattern("EEEE",Locale.US);
System.out.println(formatter.format(LocalDateTime.now()));
Choose the correct output.
Friday
34) Which of these should be used to show package-level and class-level
dependencies of Class files in Java 8
jdeps
35) LocalDate date1 = LocalDate.now();
LocalDate date2 = date1.plus(1, ChronoUnit.MONTHS);
Period period = Period.between(date2, date1);
System.out.println("Period: " + period);
Choose the correct output.
compilation error
36) 'map' and 'filter' are
Intermediate operation
37) Which of the following is correct about Java 8 lambda expression?
Both the options mentioned
38) In java 8, Static methods cannot be added to a Interface
True
39) ZoneId zoneId=ZoneId.of("Asia/Singapore");
ZonedDateTime.of(LocalDateTime.now(),zoneId);
System.out.println(ZonedDateTime.getOffset());
Assume that the offset value for Asia/Singapore time zone from UTC/Greenwich
is +08:00. Choose the correct option.
Prints +08:00 [Asia/Singapore]
40) import java.time.Clock;
public class App{
public static void main(String [] args){
final Clock clock=Clock.systemUTC();
System.out.println(clock.instant());
System.out.println(clock.millis());
}
}
Output for the above code is
compile and execute without any error
o/p : 2018-02-02T09:29:13.516611Z

1517563753614

41) Which of the following can be a valid input for jdeps dependency analyzer?
All the options mentioned
42) Example of functional interfaces in Java 8

This study source was downloaded by 100000797727937 from CourseHero.com on 04-01-2023 06:49:17 GMT -05:00

https://www.coursehero.com/file/62000114/Java-Innardstxt/
Both
43) Which of the following is the correct lambda expression which add two
numbers and return their sum?
Both
44) LocalDate date1 = LocalDate.now();
LocalDate date2 = date1.plus(1, ChronoUnit.MONTHS);
Period period = Period.between(date2, date1);
System.out.println("Period: " + period);
Choose the correct output.
Period: P-1M
45) Lambda Expressions in Java allow us to treat
Code as data
46) import java.util.Optional;
public class App {
public static void main(String[] args) {
String[] str = new String[10];
str[5] = null;;
str[4] = "JAVA OPTIONAL CLASS EXAMPLE";
Optional<String> checkNull = Optional.ofNullable(str[5]);
if(checkNull.isPresent()){ // It Checks, value is present or not
String lowercaseString = str[5].toLowerCase();
System.out.print(lowercaseString);
}else
System.out.println("String value is not present");
}
}
Choose the correct output.
String value is not present
*false 47) Object o = () -> {System.out.println(�Example�); }; Object o can be
replaced with ?
All the options mentioned

This study source was downloaded by 100000797727937 from CourseHero.com on 04-01-2023 06:49:17 GMT -05:00

https://www.coursehero.com/file/62000114/Java-Innardstxt/
Powered by TCPDF (www.tcpdf.org)

You might also like