WorksheetsLambda expressions, few more things
Total questions: 43
Worksheet time: 14mins
Name
Class
Date
1.
How to add multiple statements in a lambda expression in Java?
a)
You cannot add multiple statements in a lambda expression
b)
By separating statements with a comma
c)
By enclosing the statements in curly braces { }
d)
By using semicolons to separate statements
2.
Can a lambda expression have multiple expressions?
a)
Yes, as many as you want
b)
No, lambda expressions can only have one expression
c)
Only if they are of the same type
d)
Only if the expressions are related
3.
What are the three things that a lambda expression contains?
a)
Arguments, body, and return type
b)
Parameters, logic, and type
c)
Inputs, operation, and output
d)
Variables, code, and result
4.
What are the three main parts of a lambda expression in Java?
a)
Parameters, body, and return type
b)
Variables, logic, and type
c)
Inputs, operation, and output
d)
Arguments, code block, and result
5.
How to add multiple string values in Java?
a)
Use the + operator
b)
Use the concat() method
c)
Use the append() method
d)
Use the join() method
6.
How do you add multiple values to a variable in Java?
a)
By using a loop
b)
By assigning each value one by one
c)
By using the += operator
d)
By using the add() method
7.
Can a lambda have multiple inputs?
a)
No, lambdas can only have one input
b)
Yes, lambdas can have multiple inputs separated by commas
c)
Only if the inputs are of the same data type
d)
Only if the inputs are integers
8.
What is the limitation of a lambda expression?
a)
Lambdas cannot be used with collections
b)
Lambdas cannot have a return type
c)
Lambdas cannot contain more than one line of code without curly braces
d)
Lambdas cannot be passed as arguments to methods
9.
Can a lambda function take two arguments?
a)
No, lambdas can only take one argument
b)
Yes, lambdas can take multiple arguments
c)
Only if the arguments are of different data types
d)
Only if the arguments are integers
10.
How does a lambda work in Java?
a)
By defining a separate class for each lambda
b)
By dynamically generating bytecode
c)
By using the lambda keyword
d)
By using the new keyword
11.
What are the types of lambda?
a)
Unary, binary, and ternary
b)
Anonymous and named
c)
Consumer, Function, and Predicate
d)
Static and dynamic
12.
What are the two types of lambda expressions?
a)
Inline and multiline
b)
Anonymous and named
c)
Static and dynamic
d)
Short and long
13.
Why is it called a lambda expression?
a)
Because it's named after a famous computer scientist named "Lambda"
b)
Because it uses the Greek letter lambda (λ) to represent an anonymous function
c)
Because it's a combination of "laptop" and "panda"
d)
Because it's a random name chosen by developers
14.
What is the type of lambda in Java?
a)
lambda
b)
Lambda
c)
->
d)
Function
15.
What type of function is a lambda in Java?
a)
Anonymous function
b)
Static function
c)
Dynamic function
d)
Named function
16.
How to take three inputs in Java?
a)
By using an array
b)
By using three separate variables
c)
By using a lambda expression
d)
By using a single variable
17.
How to add three strings in Java?
a)
By using the concat() method
b)
By using the + operator
c)
By using the append() method
d)
By using the join() method
18.
How to input three integers in Java?
a)
By using a lambda expression
b)
By using a loop
c)
By using three separate variables
d)
By using the next() method
19.
How to add three variables in Java?
a)
By using the + operator
b)
By using the add() method
c)
By using the append() method
d)
By using the sum() method
20.
How to add multiple values to a key in Java?
a)
By using a lambda expression
b)
By using the put() method with a list of values
c)
By using the append() method
d)
By using the join() method
21.
How to add multiple objects in Java?
a)
By using the append() method
b)
By using the + operator
c)
By using the add() method
d)
By using the insert() method
22.
How do you use a lambda with two variables?
a)
By using two separate lambda expressions
b)
By using a single lambda expression with two parameters
c)
By using a lambda expression with a single parameter
d)
By using a lambda expression with a for loop
23.
What is the maximum size of a Lambda expression in Java?
a)
128 bytes
b)
256 bytes
c)
512 bytes
d)
There is no fixed maximum size
24.
What is the size limit of Lambda in Java?
a)
128 bytes
b)
256 bytes
c)
512 bytes
d)
There is no fixed size limit
25.
What is the disadvantage of Lambda in Java?
a)
Lambdas cannot be used with collections
b)
Lambdas can only be used with primitive data types
c)
Lambdas may lead to less readable code for complex logic
d)
Lambdas are slower than traditional Java methods
26.
Can I duplicate a lambda function?
a)
Yes, you can duplicate a lambda function
b)
No, each lambda expression must be unique
c)
Only if the lambda function is static
d)
Only if the lambda function has no parameters
27.
Can a lambda have multiple event sources?
a)
Yes, a lambda can have multiple event sources
b)
No, a lambda can have only one event source
c)
Only if the event sources are of the same type
d)
Only if the event sources are integers
28.
Can lambda functions run concurrently?
a)
Yes, lambda functions can run concurrently
b)
No, lambda functions always run sequentially
c)
Only if they are declared as static
d)
Only if they are executed in a loop
29.
What is the benefit of lambda in Java?
a)
Lambdas make code less concise
b)
Lambdas make code more difficult to read
c)
Lambdas simplify the syntax for defining small, one-off functions
d)
Lambdas increase code verbosity
30.
What is the return type of a lambda expression?
a)
It depends on the context in which the lambda is used
b)
It is always void
c)
It is specified explicitly in the lambda definition
d)
It is always int
31.
What is stream() in Java?
a)
A method for playing audio files
b)
A class for handling keyboard input
c)
A feature for processing sequences of elements
d)
A method for drawing graphics
32.
What is called a lambda?
a)
A type of variable
b)
An anonymous function
c)
A method for creating classes
d)
A data structure in Java
33.
What is lambda used for?
a)
Managing database connections
b)
Sorting arrays
c)
Defining small, one-off functions
d)
Drawing graphics
34.
What is a lambda variable?
a)
A variable declared inside a lambda expression
b)
A variable declared with the lambda keyword
c)
A variable that cannot be modified
d)
A variable used to store lambda expressions
35.
Are lambda expressions used in Java?
a)
Yes, extensively
b)
No, Java does not support lambda expressions
c)
Only in advanced Java applications
d)
Only in legacy Java code
36.
How many functions can a lambda have?
a)
Only one function per lambda
b)
As many as needed
c)
Two functions per lambda
d)
None, lambdas do not have functions
37.
What are lambda expressions good for?
a)
Solving complex mathematical equations
b)
Simplifying the syntax for defining small, one-off functions
c)
Managing database connections
d)
Creating graphical user interfaces
38.
Why was lambda created in Java?
a)
To make Java code longer and more complex
b)
To simplify the syntax for defining small, one-off functions
c)
To replace traditional Java methods
d)
To discourage the use of anonymous classes
39.
Is lambda a data type in Java?
a)
Yes, it is a primitive data type
b)
No, it is not a data type
c)
Yes, it is an object data type
d)
Yes, it is an array data type
40.
Is Java lambda a closure?
a)
Yes, Java lambda expressions are closures
b)
No, Java lambda expressions are not closures
c)
Only if explicitly declared as closures
d)
Only when used with streams
41.
Is Java lambda an object?
a)
Yes, every lambda is an instance of a class
b)
No, lambdas are not objects
c)
Only if explicitly declared as objects
d)
Only when used with arrays
42.
Is lambda a keyword or a function?
a)
A keyword
b)
A function
c)
Both a keyword and a function
d)
Neither a keyword nor a function
43.
Is a lambda function mutable?
a)
Yes, lambda functions can be modified after creation
b)
No, lambda functions are immutable
c)
Only if explicitly declared as mutable
d)
Only when used with arrays
100 %
