Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 399 Weeks Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 13 Jul 2017 My Price 15.00

code fragment

QUESTION 1

What is the error in the following code fragment?

double data[] = new double[20];

data[20] = 15.25;

  A.

A cast is required

  B.

Out-of-bounds error

  C.

A two-dimensional array is required

  D.

Data not initialized

4 points   

QUESTION 2

What is the value of sum after the following code fragment?

int sum = 0;

for (int i = 1; i <= 5; i++)

     sum = sum + i;

  A.

21

  B.

6

  C.

5

  D.

15

4 points   

QUESTION 3

What is the value of x after the following nested loop?

int x = 0;

for (int i = 0; i <= 3; i++)

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

          x = x + j;

  A.

0

  B.

3

  C.

4

  D.

12

4 points   

QUESTION 4

Which of the following is equivalent to balance = balance + amount; ?

  A.

balance == amount;

  B.

balance ++ amount;

  C.

balance += amount;

  D.

balance =+ amount;

4 points   

QUESTION 5

Which of the following indicates that a method does not return a value?

  A.

void

  B.

float

  C.

double

  D.

public

4 points   

QUESTION 6

The Java compiler ignores any text between  ____.

  A.

/* and */

  B.

*/ and */

  C.

/# and #/

  D.

/ and /

4 points   

QUESTION 7

Which one of the following is a valid header for a constructor for a class called Car?

  A.

Public void Car()

  B.

public Car(String model)

  C.

public class Car(String model)

  D.

public car(String model)

4 points   

QUESTION 8

In Java, the = operator

  A.

causes output to appear in the BlueJ Terminal Window

  B.

tests for equality

  C.

sets a variable to the given value

  D.

has no definition

4 points   

QUESTION 9

In Java, the statement

days++;

has the same effect as

  A.

days = days + 1;

  B.

days = days + days;

  C.

days + 1 = days;

  D.

days = 1;

4 points   

QUESTION 10

Which of the following are Java naming conventions?

#1:       Classes start with an uppercase letter


#2:       Methods (except for the constructor) start with an uppercase letter


#3:       Objects start with a lowercase letter


#4:       Objects start with an uppercase letter


#5:       Classes start with a lowercase letter


#6:       Methods (except for the constructor) start with a lowercase letter

  A.

#4, #5 and #6

  B.

#1, #2 and #4

  C.

#1, #3 and #6

  D.

#3, #5 and #6

4 points   

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]

4 points   

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[];

4 points   

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");

4 points   

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

4 points   

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

4 points   

QUESTION 16

Remember that the % operator evaluates to the remainder after integer division e.g. 8 % 4 is 0, 11 % 4 is 3.  What is the value of x after the following?

int x = 0;
for (int i = 1; i < 6; ++i)
    if (i % 2 == 0)
        x = x + i;

  A.

0

  B.

15

  C.

6

  D.

21

4 points   

QUESTION 17

Assume that mynums is an array of 5 integers. What will be the contents of mynums after the following code fragment?

for (int i = 0; i < 5; i++)
    mynums[i] = i + 1;

  A. 1 2 3 4 5
  B. 0 1 2 3 4
  C. 1 2 3 4
  D. 1 1 1 1 1

4 points   

QUESTION 18

What is the effect of the following code fragment?

for (double element : values) element = 0;

  A.

The elements of the array named values are initialized to zero

  B.

The elements of the array named element are initialized to zero

  C.

The first element of the array named values is initialized to zero

  D.

The elements of the array named values are not modified

4 points   

QUESTION 19

The following statement accesses the element at index 4 in an array:

x = a[4];

What is the equivalent operation using an array list?

  A.

x = a.get(4);

  B.

x = a.get();

  C.

x = a.get[4];

  D.

x = a[4];

4 points   

QUESTION 20

Assume that values is an array of random integers. Which condition must be used in the indicated area so the code fragment below will set max to the largest value in values?

int max = values[0]; for (int val: values) { if (/* put condition here */) max = val; }

  A. max > val
  B. val > max
  C. values[val] > max
  D. max > values[val]

4 points   

QUESTION 21

Assume that names is an empty ArrayList of String. What will be the contents of names after the following code fragment?

names.add("Annie"); names.add("Bob"); names.add("Charles"); for (int i = 0; i < 3; i++) { String extra = names.get(i); names.add(extra);

}

  A.

Annie Bob Charles Annie Bob Charles

  B.

Annie Bob Charles Charles Bob Annie

  C.

Annie Annie Bob Bob Charles Charles

  D.

Annie Bob Charles Bob Charles

4 points   

QUESTION 22

What is the value of num after the following code fragment?

int num = 3; num++;

  A.

2

  B.

3

  C.

4

  D.

5

4 points   

QUESTION 23

What is the value of num after the following code fragment?

int num = 3; num = num A????1 2 * num; num++;

  A.

A????12

  B.

0

  C.

2

  D.

4

4 points   

QUESTION 24

What are the values of num1 and num2 after the following code fragment?

double num1 = 4.2;

double num2 = num1 * 10 + 5.0;

  A.

num1 is 4.2 and num2 is 63.0

  B.

num1 is 4.2 and num2 is 47.0

  C.

num1 is 42.0 and num2 is 42.0

  D.

num1 is 42.0 and num2 is 47.0

4 points   

QUESTION 25

What is the value of price after the following code fragment?

double price = 30.0; double discount = 10.0; price = price - price * (discount / 100.0);

  A.

30.0

  B.

20.0

  C.

27.0

  D.

33.0

Answers

(5)
Status NEW Posted 13 Jul 2017 07:07 PM My Price 15.00

Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- Th-----------ank----------- Yo-----------u f-----------or -----------usi-----------ng -----------our----------- we-----------bsi-----------te -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill-----------

Not Rated(0)