Answered You can hire a professional tutor to get the answer.

QUESTION

Which of the following couldnotbe a constructor for the public class

Which of the following could not be a constructor for the public class

SomeClass?

  1. SomeClass()
  2. int SomeClass()
  3. SomeClass(int a, String s)

 Statement I only

 Statement II only

 Statement III only

 Statements I and II only

 Statements I and III only

Question 12

Which of the following would be best handled with an ArrayList?

 A list of all the states in the United States

 A list of cars that get 30 miles per gallon or better

 The names of the Seven Dwarfs

 A list of the ASCII code values

 A list of astronauts who have walked on the moon

Question 13

Assume that aList is a valid ArrayList containing the following:

Wei, Marila, Anna, Neal, Rachel, Jack, Aneesh

Which of the following does not remove Anna from aList?

  1. aList.remove("Anna", 3);
  2. aList.remove(2, "Anna");
  3. aList.remove(2);

 Statement I only

 Statement II only

 Statement III only

 Statements I and II only

 Statements II and III only

Question 14

Given the following class:

import java.util.ArrayList;

public class RectangleTester

{

     public static void main(String[ ] args)

     {

          ArrayList< Rectangle > shapes = new ArrayList< Rectangle >();

          shapes.add(new Rectangle(1, 1));

          shapes.add(new Rectangle(2, 2));

          shapes.add(new Rectangle(3, 3));

          shapes.add(new Rectangle(4, 4));

          Rectangle dataRecord;

          for(int index = 0; index < shapes.size(); index++)

          {

               dataRecord = shapes.get(index);

               dataRecord.calcRectArea();

               dataRecord.calcRectPerimeter();

               System.out.println("Area = " + dataRecord.getArea());

               System.out.println("Perimeter = " + dataRecord.getPerimeter());

          }

     }

}

Assume that getArea() returns the area of a rectangle and getPerimeter() returns the perimeter of a rectangle. What will print when index = 0?

 Area = 9

Perimeter = 12

 Area = 4

Perimeter = 8

 Area = 16

Perimeter = 16

 Area = 25

Perimeter = 20

 Area = 1

Perimeter = 4

Question 15

Assume that aList is a valid ArrayList containing the following:

Wei, Marila, Anna, Neal, Rachel, Jack, Aneesh

When the following statement executes, what does aList contain?

aList.set(1, "Beth");

 Wei, Marila, Anna, Neal, Rachel, Jack, Aneesh

 Wei, Beth, Anna, Neal, Rachel, Jack, Aneesh

 Wei, Beth, Marila, Anna, Rachel, Jack, Aneesh

 Beth, Marila, Anna, Neal, Rachel, Jack, Aneesh

 Beth, Wei, Marila, Anna, Neal, Rachel, Jack, Aneesh

Question 16

Assume that the following numbers belonged to an ArrayList called values:

5, 23, 45, −3, 17, 18, 100

Which of the following would determine how many elements are in values?

 int numElements = values.length;

 int numElements = values.length();

 int numElements = values.size();

 int numElements = values.size;

 double numElements = values.size;

Question 17

Which of the following does not indicate a Javadoc's comment?

  1. //
  2. /*
  3. /**

 Statement I only

 Statement II only

 Statement III only

 Statements I and II only

 Statements I and III only

Question 18

Given the following class

public class Magazine

{

     private double discountRate;

     private String title;

     private String publisher;

     private double newsstandPrice;

     public Magazine(String theTitle, String thePublisher, double theNewsPrice)

     {

          title = theTitle;

          publisher = thePublisher;

          newsstandPrice = theNewsPrice;

          double discountRate = 0.60;

     }

     public String getTitle()

     {

          return title;

     }

     public String getPublisher()

     {

          return publisher;

     }

     public double getNewsstandPrice()

     {

          return newsstandPrice;

     }

     public double getDiscRate()

     {

          return discountRate;

     }

     public double getSubscriptionPrice()

     {

          // implementation not shown

     }

     public void setNewsstandPrice(double newPrice)

     {

          newsstandPrice = newPrice;

     }

}

How many mutator methods does the Magazine class have?

 0

 1

 2

 3

 4

Question 19

Assume that aList is a valid ArrayList containing the following:

5.3, 15.1, 8.2, 6.3, 24.1, 2.0, 4.1

Which of the following places −100 immediately before 15.1 in aList?

 aList.add(2, −100);

 aList.add(−100);

 aList.add(1, −100);

 aList.add(15.1, −100);

 aList.add(−100, 1);

Question 20

What is the purpose of a class constructor?

 To provide access to an instance variable

 To initialize the instance variables

 To invoke a class method

 To calculate return values for the class

 To provide client code for the class

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question