Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is java Questions, Please help... Question 1 What is the value of x after t

ID: 3761251 • Letter: T

Question

This is java Questions, Please help...

Question 1

What is the value of x after the following statement is executed?

double x = Math.floor(Math.abs(Math.ceil(3.1) + Math.floor(12.99) - 20.5));

Question 2

Select those code excerpts below that are valid.

promo(21.7);

}

static void promo(int param) {

// ...

}

promo(discount);

}

static void promo(double param) {

// ...

}

promo(10.5);

}

static void promo(float param) {

// ...

}

promo(10);

}

static void promo(float param) {

// ...

}

promo((int) 21.7);

}

static void promo(int param) {

// ...

}

public static void main(String args[]) {

promo(21.7);

}

static void promo(int param) {

// ...

}

public static void main(String args[]) { float discount = 10.5f;

promo(discount);

}

static void promo(double param) {

// ...

}

public static void main(String args[]) {

promo(10.5);

}

static void promo(float param) {

// ...

}

public static void main(String args[]) {

promo(10);

}

static void promo(float param) {

// ...

}

public static void main(String args[]) {

promo((int) 21.7);

}

static void promo(int param) {

// ...

}

Explanation / Answer

Question1 x = 4.0


//Invalid code because of lossy conversion from double to int

public static void main(String args[]) {

promo(21.7);

}

static void promo(int param) {

// ...

}

//Valid

public static void main(String args[]) { float discount = 10.5f;

promo(discount);

}

static void promo(double param) {

// ...

}

//Invalid code because of lossy conversion from double to float
public static void main(String args[]) {

promo(10.5);

}

static void promo(float param) {

// ...

}

//Valid

public static void main(String args[]) {

promo(10);

}

static void promo(float param) {

// ...

}

//Valid
public static void main(String args[]) {

promo((int) 21.7);

}

static void promo(int param) {

// ...

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote