Java Programming Quiz

Java Programming Quiz

Assessment

Quiz

Computers

KG

Easy

Created by

Alisher Saimassay

Used 2+ times

FREE Resource

Student preview

quiz-placeholder

65 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct syntax for initializing a variable named dog, of type String, with the value "BARK"?

string dog = "BARK";

dog = "BARK";

"BARK" = String dog;

int dog = "BARK";

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Look at the following line of code: int[] myList = { 1, 2, 3, 4, 5 }; What is the proper way to access the array element with the value 3?

myList["two"];

MyList[2];

myList[3];

myList.3

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Look at the following code: int i = 4; if (i <= 3) { i = 0; } else if (i <= 6) { i = 1; } else { i = 2; } What value would i be after this if then else statement?

null

1

2

0

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Look at the following function: public String reverseName( String name1, String name2 ) { String reversed = name2 + ", " + name1; return reversed; } Which is the proper way to call this function?

reverseName()

reverseName( "John", "Doe" )

reverseName("John",100)

ReverseName("John","Doe");

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Look at the following code: public class TestClass { // section 1: private String testName; // section 2: public TestClass( String name, int i ) { this.testName = name; } // section 3: public void countToThree() { for (int m = 1; m <= 3; m++) { System.out.println( "Count is: " + m ); } } } What is defined in the denoted sections of this class?

section 1: member variable section 2: constructor section 3: class method

section 1: method section 2: constructor section 3: member variable

Section 1: member variable. Section 2: constructor. Section 3: method.

section 1: member variable section 2: class method section 3: method

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

As an established Java convention, what would it mean if the name of a variable was spelled in all uppercase?

The variable is a constant, whose value should not change.

the variable is contains a string that has all capital letters

the variable is reserved for use by the Java environment, and you should not refer to it

nothing. There is no such convention, and such a variable is like any other

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Look at the following code: int errorInteger = 200; String comment; switch (errorInteger) { case 150: comment = "Javascript error."; break; case 240: comment = "Comment error."; break; case 300: comment = "Function error."; break; case 200: comment = "New error."; break; default: comment = "No error."; break; } System.out.println( comment ); What would be the resulting output from this code?

javascript error

comment error

function error

New error.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?