Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) How many times is the println statement executed? for ( int i=0; i <5; i++ ) { for ( int j=0; j

1) How many times is the println statement executed?

for ( int i=0; i<5; i++ ) { for ( int j=0; j 

2)

The proper way to re-write the following code using the short handed method is:

count = count + 25;

3)

What modifier do we add to the instance variable name to make it hidden?

public class Player { _______________ String name; public Player() { this.name = ""; } public void setName( String newName ) { this.name = newName; } public String getName() { return this.name; } }

4)

Match the following symbols with their purpose.

Arrays

[ Choose ] {} [] () "" ''

Blocks

[ Choose ] {} [] () "" ''

Precedence

[ Choose ] {} [] () "" ''

Strings

[ Choose ] {} [] () "" ''

Characters

5)

Consider the following code:

int[][] form = new int[2][5]; for ( int i=0; i<2; i++ ) { for ( int j=0; j<5; j++ ) { form[i][j] = i+4*j; } }

Match the indices of the array to the answers provided

form[0][1]

[ Choose ] 5 13 4 invalid 8

form[1][1]

[ Choose ] 5 13 4 invalid 8

form[2][4]

[ Choose ] 5 13 4 invalid 8

form[0][2]

[ Choose ] 5 13 4 invalid 8

form[1][3]

6)

The following code compiles correctly but creates a run-time error, correct the code so it runs correctly.

int[] b = new int[10]; int i; for ( i=1; i<=b.length; i++ ) { b[i] = 5 * i; } 

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

More Books

Students also viewed these Databases questions