Question: QUESTION 1 Consider the following line of Java code: float h = Math.E * 123.45; What primitive data type Java will assume 123.45 is? double

QUESTION 1

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 2

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 3

Which identifier is illegal in Java?

broke

break

broken

brake

QUESTION 4

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 5

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!