Question: Question 1 A runtime error will never be found by the compiler. Question 1 options: True False Question 2 A pair of braces {} is

Question 1

A runtime error will never be found by the compiler.

Question 1 options:

True
False

Question 2

A pair of braces {} is mandatory for any kind of if, while, for statements.

Question 2 options:

True
False

Question 3

Object variables (variables of class type) store ____.

Question 3 options:

-

classes

-

references(memory addresses

-

numbers

-

values

Question 4

Consider this code fragment.

double balance = 13.75; 
int dollars = balance; 

Which of the following statements is true?

Question 4 options:

-

The code compiles and runs correctly, setting dollars to 13.

-

The code compiles but it sets dollars to a wrong value due to a roundoff error.

-

The code compiles but it sets dollars to the nearest integer, 14.

-

The code doesn't compile because you cannot assign double value to int variable.

Question 5 (1 point)

The value of the Java expression 11 / 4 is _________________ .

Question 5 options:

-

2.75

-

3

-

11

-

2

Question 6

Assume that we have defined two variables:

String str1 = "text 1";

String str2 = "text 2";

The expression str1 != str2 is used to compare if the contents of str1 and str2 are not identical.

Question 6 options:

True
False

Question 7

In the following code sample:

int i; for (i = 0; i  

The very last value from user input will be correctly printed to screen.

Question 7 options:

True
False

Question 8

Given an array of integer defined as follow:

int[] arr = new int[5];

choose all correct statements about this array.

Question 8 options:

-

arr.length equals 5

-

arr.length() returns 5

-

it is not compilable because of syntax error

-

arr[0] is the first int value stored in the array

Question 9

What is(are) the correct boolean expression(s) to check if the user input string usrInput starts with a letter 'n'

Question 9 options:

-

usrInput.substring(0, 1).equals("n");

-

usrInput.charAt(0).equals("n");

-

usrInput.charAt(1) == 'n'

-

'n' == usrInput.charAt(0)

Question 10

What is the Java statement to read value from user and store in the last element of the array? Given the following context:

Scanner scnr = new Scanner(System.in); int size = 7; int[] arr = new int[size];

Question 10 options:

-

arr[7] = scnr.nextInt();

-

arr[size] = scnr.nextInt();

-

scnr.nextInt(arr[7])

-

arr[size - 1] = scnr.nextInt();

Question 11

What is the correct way to call the method defined as following:

public static int calcArea(int height, int width) { ... }

Question 11 options:

-

double area = calcArea(10, 20);

-

int h = 10;

int w = 20;

int area = calcArea(int h,int w);

-

int area = calcArea(1.5, 2);

-

int h = 10;

int w = 20;

int area = calcArea(h, w);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!