Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please try to explain the answers as well. It will be highly appreciated. Output of the following expression: 5 * 4 % 2 = ?

Please try to explain the answers as well. It will be highly appreciated.

  • Output of the following expression:

5 * 4 % 2 = ?

  • Output of a loop:
    • Example: What will be the output of the Java code (Assume all variables are properly declared.)

num = 10;

while (num <= 32)

num = num + 5;

System.out.println(num);

  • What will be the output of the Java code (Assume all variables are properly declared.)

public class test

{

public static void main(String[] args)

{

int n1 = 8;

int n2 = 3;

double answer = (double ) n1 / n2;

System.out.println(The answer is + answer);

}

}

Note: Check with and without type casting.

  • What will be the output of the Java code (Assume all variables are properly declared.)

for (int i = 1; i <= 3; i++)

{

for (int j = 2; j <= 3; j++)

{

System.out.println(I + ,+ j);

}

}

Answer:

  • Question:

Suppose x = 19.5. What will be the output of the statement

System.out.println((int)(x) % 3);

  • What will the output of the following Java code (Assume all variables are properly declared and the input is 3 4 1).

num = console.nextInt();

sum = num;

while (num != -1)

{

num = console.nextInt();

sum = sum + num;

}

Answer:

  • What is the output of the following code Fragment?

int i =10;

while(true)

{

i = i-1;

if(i<= 6)

break;

System.out.print(i+ " ");

}

Answer:

  • What is the output of the following Java code:

int alpha = 5;

int beta = 4;

switch (beta)

{

case 2:

alpha = alpha + 2;

case 4:

alpha = alpha + 4;

break;

case 6:

alpha = alpha + 6;

default:

alpha = alpha + 10;

}

System.out.print(alpha);

a. 7 c. 11

b. 9 d. 15

  • What is the output of the following code?

int i;

int result = 5;

for (i = 0; i <= 2; i++)

{

result = result + 2;

System.out.print(result + " ");

}

Write a line of code to call a method named printMe. The method has no return value and no arguments.

Find one error:

if (answer = male)

{

//comment

}

else (answer == female)

{

//comment

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

What is job enlargement ?

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago