Search Header Logo

Java Programming - Quiz 1

Authored by Shom Das

University - Professional Development

Used 49+ times

Java Programming - Quiz 1
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given the following,

1. public class Test {

2. public static void main(String [] args) {

3. signed int x = 10;

4. for (int y=0; y<5; y++, x--)

5. System.out.print(" " + x);

6. }

7. }


what is the result? (Choose one.)

10 9 8 7 6

9 8 7 6 5

Compilation fails

An exception is thrown at runtime

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which one of these lists contains only Java programming language keywords? (Choose one.)

class, if, void, long, Int, continue

goto, instanceof, native, finally, default, throws

try, virtual, throw, final, volatile, transient

strictfp, constant, super, implements, do

byte, break, assert, switch, include

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the numerical range of a char? (Choose one.)

–128 to 127

–(2 ^ 15) to (2 ^ 15) - 1

0 to 32767

Platform dependent

0 to 65535

4.

MULTIPLE SELECT QUESTION

30 sec • 1 pt

Which three are valid declarations of a float? (Choose three.)

float f1 = -343;

float f2 = 3.14;

float f3 = 0x12345;

float f6 = 2.81F;

float f5 = 2001.0D;

5.

MULTIPLE SELECT QUESTION

30 sec • 1 pt

Which two demonstrate encapsulation of data? (Choose Two)

Member data have no access modifiers.

Member data can be modified directly.

The access modifier for methods is protected.

The access modifier to member data is private.

Methods provide for access and modification of data.

6.

MULTIPLE SELECT QUESTION

30 sec • 1 pt

Which two valid declarations of a char? (Choose Two)

char ch = “a”;

char ch = ‘\’ ‘;

char ch = ‘cafe’;

char ch = ‘\ucafe’;

char ch = (char) true;

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given:

1. public class returnIt (

2. returnType methodA(byte x, double y) (

3. return (short) x/y * 2;

4. )

5. )

What is the valid returnType for methodA in line 2 ?

int

double

long

short

float

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?