Question: QUESTION 1 In Java a block of code (a group of statements) is enclosed in? any of these will do braces {} parentheses () brackets

QUESTION 1

In Java a block of code (a group of statements) is enclosed in?

any of these will do

braces {}

parentheses ()

brackets []

QUESTION 2

Assume that a and b are two declared and initialized variables of type double. Consider the following line of Java code:

int c = (int) a / b;

Which variable(s), if any, will explicit casting be applied to in this expression?

a

b

Neither a nor b

Both a and b

QUESTION 3

Consider the following Java identifier:

STATUS

Following the naming convention suggested in lecture slides, what is STATUS most likely going to represent?

This is not a valid identifier

A constant

A class name

A method name

QUESTION 4

Assume that a and b are two declared and initialized variables. Variable a is of type double. Variable b is of type int. Consider the following line of Java code:

b = a;

What kind of type casting, if any, is necessary here?

Explicit casting

Implicit casting

Both implicit and explicit casting

There is no need for casting at all

QUESTION 5

Consider the following line of Java code (you can assume that there are no errors here):

k = (Math.PI + x) * 4.56;

Which part of this expression is considered to be a literal?

Math.PI

4.56

x

k

QUESTION 6

Consider the following line of Java code:

float h = Math.E * 123.45;

What primitive data type Java will assume 123.45 is?

double

long

int

float

QUESTION 7

Assume that pies and people are two declared and initialized variables of type int. Also, assume that piesPerPerson is a declared and initialized variable of type float. Consider the following line of Java code (This line has issues, BTW. Think why):

piesPerPerson = (float)(pies/people);

What Java operations are involved here?

variable declaration, implicit casting, integer division

variable declaration, explicit casting, integer division

variable assignment, explicit casting, integer division

variable assignment, implicit casting, integer division

QUESTION 8

Which identifier is illegal in Java?

broke

break

broken

brake

QUESTION 9

What is modulo operation doing in Java?

It returns a result of a division operation

It rounds a floating point number to the nearest integer greater than that floating point number

It returns a remainder of a division operation

It returns a fractional/decimal part of a floating point number

QUESTION 10

Assume that a and b are two declared and initialized variables. Variable a is of type double. Variable b is of type int. Consider the following line of Java code:

a = b;

What kind of type casting, if any, is necessary here?

There is no need for type casting here at all

Explicit casting

Implicit casting

Both implicit and explicit casting

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!