Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 11 Given an array of int called scores, which of the following will access the first element of the array? A. scores[1] B. scores.length

QUESTION 11

Given an array of int called scores, which of the following will access the first element of the array?

A.

scores[1]

B.

scores.length - 1

C.

scores.length

D.

scores[0]

QUESTION 12

Which of the following will allocate memory to hold an array of 10 int values?

A.

int scores[] = new int[9];

B.

int scores;

C.

int scores[] = new int[10];

D.

int scores[];

QUESTION 13

Re-write the following using a for loop

int z = 99; while (z >= 12) { System.out.print("z is: "); System.out.println(z); z = z - 3; } System.out.println("done");

A.

for (int z = 99; z >= 12; z = z - 3) { System.out.print("z is: "); } System.out.println(z); System.out.println("done");

B.

for (int z = 99; z >= 12; ++z) { System.out.print("z is: "); System.out.println(z); z = z - 3; } System.out.println("done");

C.

for (int z = 99; z >= 12; z = z - 3) System.out.print("z is: "); System.out.println(z): System.out.println("done");

D.

for (int z = 99; z >= 12; z = z - 3) { System.out.print("z is: "); System.out.println(z); } System.out.println("done");

QUESTION 14

What is the value of x after the following?

int x = 0; for (int i = 2; i <= 14; i = i + 3) x = x + i;

A.

0

B.

26

C.

40

D.

57

QUESTION 15

Given the following class definition:

public class Foo { private int bar;

public Foo(int i) { bar = i; }

public void wah(int i) { bar = bar + i; }

public void dah() { System.out.print(bar); } }

and executing this code segment:

Foo f = new Foo(20); f.wah(10); f.dah();

What value will be output?

A.

0

B.

10

C.

20

D.

30

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

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions