Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MCQ !! Question 1 Which of the following are valid Java Identifiers? Choose all that apply. 1AGE age1 Tax Test Variable a-javapoint java_&_point a555c sum

MCQ !!

Question 1

Which of the following are valid Java Identifiers? Choose all that apply.

1AGE

age1

Tax

Test Variable

a-javapoint

java_&_point

a555c

sum & difference

00xTrick

SpEcIaL_vAlUe

QUESTION 2

What will be the output of this code?

int x = 12; int y = 14; x = x + y; y = x - y; x = x - y; System.out.print(x);

Question 3

Given the following int (integer) variables, a = 4, b = 4, c = 34, d = 5, evaluate the expression:

a * b + (c / d)

Question 4

Evaluate this logical expression:

! true || true 

True

False

Question 5

Evaluate this expression: 3 > 2

True

False

Question 6

Evaluate this expression: 7 + 2 <= 3 || 16 - 6 > 1

True

False

Question 7

Which of the following are Java primitive data types? Choose all that apply.

real

boolean

double

class

Math

float

char

String

Random

Array

Question 8

Which of the following Java literals have the data type float? Choose all that apply.

-3f

' '

8.8

"true"

123.0

-3

"3.0"

'a'

false

3.14

123f

true

Question 9

When the following expression is evaluated, the result will be what Java data type?

90 - 99

1) int 2) float 3) double 4) boolean 5) char 6) String 7) none of these

Your answer should be the number (1 - 7) next to the correct data type name.

Question 10

Which of the following would be the best data type for a variable to store the average score on the final exam?

none of these

char

int

float

String

boolean

Question 11

Write a line of Java code that will declare a int variable named y that is initialized to the value -67.

Question 12

What will this small program output?

classMain{ publicstaticvoidfoo(){ int x = 9; System.out.println(x); }  publicstatic intx=20;  publicstaticvoidmain(String[]args){ x = 30; foo(); } }

Question 13

What is the output of this Java program?

class Driver { public static void main(String[] args) { foo(8); bar(1); } static void foo(int a) { System.out.print(a); bar(a - 1); } static void bar(int a) { System.out.print(a); } }

Question 14

What is the output of this Java program?

class Driver { public static void main(String[] args) { int a = bar(2); int b = foo(a); } static int foo(int a) { System.out.print(a); a = bar(a - 0); return a; } static int bar(int a) { System.out.print(a); return a + 2; } }

Question 15

What is the output of this Java program?

class Driver { public static void main(String[] args) { int a = 4; int b = 5; int c = 8; int x = 1; if (a > 2) { x = x + 400; } if (b < 8) { x = x + 50; } if (c < 8) { x = x + 8; } System.out.print(x); } } 

Question 16

What is the output of this Java program?

class Driver { public static void main(String[] args) { int a = 5; int b = 6; int c = 8; int x = 1; if (a < 8) { x = x + 500; } if (b < 4) { x = x + 60; } if (c < 7) { x = x + 8; } System.out.print(x); } }

Question 17

What will be the output of this code?

int a = 14; int b = 17; int x = 14;  if (a > b) { x = 16; } else { x = 2; }  System.out.print(x);

Question 18

What will this small program output?

int a = 3; int b = 13; int c = 15; int x = 2;  boolean y = a <= b; boolean z = a <= c; if (y && z) { x = 17; } else { x = 5; }  System.out.print(x); 

Question 19

What is the output of this Java program?

class Driver { public static void main(String[] args) { int a = 32; int b = 29; if (a > 46) if (b < 32) System.out.print(a); else System.out.print(b); else System.out.print(a + b); } }

Question 20

What will this small program output?

int a = 11; int b = 4; int c = 16; int x = 9;  if (a > b) { x = 2; } else if (a > c) { x = 3; } else if (b > c) { x = 11; } else { x = 7; }  System.out.print(x);

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

Step: 3

blur-text-image

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions