Lambda expressions eliminate the need for ________.

  • Anonymous inner classes
  • Arrays
  • Inheritance
  • Interfaces
Lambda expressions eliminate the need for anonymous inner classes. Before lambda expressions were introduced in Java, anonymous inner classes were used to implement single-method interfaces, like Runnable or ActionListener. Lambda expressions provide a more concise and expressive way to define such implementations, reducing the verbosity of code.

How does the compiler resolve the "+" operator when used with different data types (e.g., String and int)?

  • It performs the operation based on the type of the first operand and ignores the second operand's type.
  • It throws a compilation error because the + operator cannot be used with different data types.
  • It throws a runtime error because the + operator is ambiguous with different data types.
  • It uses type conversion to promote one of the operands to the type of the other operand, and then performs the operation.
It uses type conversion to promote one of the operands to the type of the other operand, and then performs the operation. For example, if you add a string and an int, the int is converted to a string, and string concatenation is performed. If you add two integers, normal addition is performed.

How can you format the print output in R, such as limiting decimal points or adding padding?

  • None of the above
  • Use the format() function
  • Use the round() function to limit decimal points and the str_pad() function to add padding
  • You cannot format the print output in R
The 'format()' function in R can be used to format the print output. This includes controlling the number of decimal places, adding padding, setting field widths, and more. For example, 'format(round(x, 2))' would round 'x' to 2 decimal places.

A variable that is defined in the global environment in R and can be accessed from anywhere in your program is a ________.

  • Global variable
  • Local variable
  • Constant variable
  • System variable
A variable that is defined in the global environment in R and can be accessed from anywhere in the program is called a global variable. Global variables are not confined to any specific function or scope and can be accessed and modified throughout the program.

The ______ function in R can be used to calculate the standard deviation of a numeric vector.

  • sd()
  • var()
  • mean()
  • median()
The sd() function in R can be used to calculate the standard deviation of a numeric vector. The sd() function computes the sample standard deviation, which measures the spread or variability of the values in the vector.

The ______ function in R can be used to add text annotations to a scatter plot.

  • text()
  • annotate()
  • label()
  • add_text()
The text() function in R can be used to add text annotations to a scatter plot. It allows you to specify the coordinates and the text to be displayed at those coordinates, providing additional information or labels within the plot.

In R, if you have a for loop inside another for loop, the inner loop executes ________ for each iteration of the outer loop.

  • Before
  • After
  • Once
  • Multiple times
In R, if you have a for loop inside another for loop, the inner loop executes multiple times for each iteration of the outer loop. This allows you to perform a block of code within the inner loop for each iteration of the outer loop.

What is the purpose of the if statement in R?

  • To conditionally execute a block of code based on a specified condition
  • To loop over a sequence of values
  • To define a function in R
  • To assign a value to a variable in R
The purpose of the if statement in R is to conditionally execute a block of code based on a specified condition. If the condition is true, the code inside the if block is executed; otherwise, it is skipped.

What is the purpose of the main parameter in the R plotting function?

  • To set the color of the plot
  • To add a legend to the plot
  • To specify the main title of the plot
  • To control the axis labels
The main parameter in the R plotting function is used to specify the main title of the plot. It allows you to provide a descriptive title that summarizes the content or purpose of the plot.

How do you structure an if-else statement in R?

  • if (condition) { code to execute if condition is true } else { code to execute if condition is false }
  • if (condition) { code to execute if condition is true } elseif (condition) { code to execute if another condition is true } else { code to execute if all conditions are false }
  • if (condition) { code to execute if condition is true } else (condition) { code to execute if condition is false }
  • if (condition) { code to execute if condition is true }
In R, an if-else statement is structured using the if keyword, followed by the condition inside parentheses. The code to execute if the condition is true is enclosed in curly braces after the if statement. The else keyword is followed by the code to execute if the condition is false, also enclosed in curly braces.