Geography, asked by jenniferalston2012, 7 months ago

write the Java expression of the following statement where X and Y are predefined variable (a. 5=5x+2y) (b. 5=3x^2+2y/x-y) (c. 5=4t+1/2at^2)​

Answers

Answered by mamtakahar7
0

Answer:

Question 1

The precedence of operators in Java follows BODMAS.

False

Question 2

The output of a++ will be 1, if int a = -1.

False

Question 3

The relational operators always result in terms of 'True' or 'False'.

True

Question 4

Given: int m=5; m*=5 then the value stored in m results in 55.

False

Question 5

The statement (a>b)&&(a>c) uses a logical operator.

True

Question 6

If int a=27,b=4,c=0; then c = a%b; results in 3.

True

Question 7

The statement p+=5 means p=p*5.

False

Question 8

In the precedence of logical operators; NOT is followed by AND.

True

Write the Java expressions for the following

Question 1

z = 5x3 + 2yx + y

Answer

z = 5 * x * x * x + 2 * y * x + y

Question 2

m = a2 + b2 / (a + b)

Answer

m = (a * a + b * b) / (a + b)

Question 3

s = ut + (1/2)at2

Answer

s = u * t + (1.0 / 2) * a * t * t

Question 4

f = uv / (u + v)

Answer

f = u * v / (u + v)

Question 5

d = √(3x + x2) / a + b

Answer

d = Math.sqrt(3 * x + x * x) / (a + b)

Question 6

p = a2 + b2 + 2ab

Answer

p = a * a + b * b + 2 * a * b

Question 7

y = 2(lb + bh + lh)

Answer

y = 2 * (l * b + b * h + l * h)

Question 8

p = a / b2 + b / a2

Answer

p = a / (b * b) + b / (a * a)

Question 9

z = x3 + y3 - y / z3

Answer

z = x * x * x + y * y * y - y / (z * z * z)

Question 10

q = 1 / √(a + b) + 3 / c2

Answer

q = (1 / Math.sqrt(a + b)) + 3 / (c * c)

Predict the output

Question 1

int c = (3<4)? 3*4:3+4;

Output

12

Explanation

As 3 is less than 4 so condition of ternary operator is true. Variable c is assigned the value of expression 1 which is 3 * 4 = 12.

Question 2

int a = 14, b = 4;

boolean x = (a > b) ? true : false;

Output

true

Explanation

As 14 is greater than 4 so condition of ternary operator is true. Variable x is assigned the value of expression 1 which is true.

Question 3

int x = 90;

char c = (x<=90)?'Z':'I';

Output

Z

Explanation

As value of x is 90 so condition of ternary operator is true. Variable c is assigned the value of expression 1 which is Z.

Question 4

int a = 18; int b = 12;

boolean t = (a > 20 && b < 15)? true : false;

Output

false

Explanation

The condition a > 20 is false as value of a is 18. So the logical AND operator — && returns false. Variable t is assigned the value of expression 2 which is false.

Question 5

c = (val + 550 < 1700)? 200: 400;

if: (a) val = 1000 (b) val = 1500

Output

(a) 200

(b) 400

Explanation

When val = 1000, val + 550 = 1550. As 1550 is less than 1700 so condition of ternary operator is true. Variable c is assigned the value of expression 1 which is 200.

When val = 1500, val + 550 = 2050. As 2050 is greater than 1700 so condition of ternary operator is false. Variable c is assigned the value of expression 2 which is 400

Similar questions