Exam 3: Using Classes and Objects

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

In addition to providing a mechanism to convert primitive data into objects, what else do the wrapper classes provide?

(Multiple Choice)
4.9/5
(39)

These two ways to set up a String will yield identical results: String my_string = new String("a bunch of words"); String my_string = "a bunch of words";

(True/False)
4.8/5
(32)

Rewrite the following five assignment statements into a single statement using prefix and postfix increment and decrement operators as necessary. Assume all variables are int variables. x = y + 1; y = y + 1; z = z - 1; x = x - z; x = x + 1;

(Short Answer)
4.7/5
(39)

The advantage(s) of the Random class's pseudorandom number generators, compared to the Math.random method, is(are) that

(Multiple Choice)
4.8/5
(37)

Problem Ch 03-1 Assume an interactive Java program which asks the user for his/her first name and last name, and outputs the user's initials. -Refer to Problem Ch 03-1. For the program to get a name interactively a Scanner object must be instantiated. Write the Java statement to do this.

(Short Answer)
4.8/5
(40)

If two variables contain aliases of the same object then

(Multiple Choice)
4.9/5
(43)

In Java a variable may contain

(Multiple Choice)
4.8/5
(35)

Assume you write a program that uses the Random class but you fail to include an import statement for java.util.Random or java.util.*. What will happen when you attempt to compile and run your program?

(Multiple Choice)
4.9/5
(35)

The following statement will display the value 127. System.out.println("123" + 4);

(True/False)
4.9/5
(27)

All the methods in the Math class are declared to be static.

(True/False)
4.9/5
(34)

Which of the following packages includes classes that represent shapes in JavaFX?

(Multiple Choice)
4.9/5
(44)

What does the following code fragment do? Circle circle = new Circle(100, 100, 50); Circle.setFill(Color.GREEN); Rectangle rectangle = new Rectangle(70, 70, 225, 75); Rectangle.setStroke(Color.BLUE); Rectangle.setStrokeWidth(2); Rectangle.setFill(null);

(Multiple Choice)
4.9/5
(36)

You may apply the prefix and postfix increment and decrement operators to instances of the Integer class.

(True/False)
5.0/5
(34)

You may use the String.replace() method to remove characters from a String.

(True/False)
4.8/5
(25)

Problem Ch 03-1 Assume an interactive Java program which asks the user for his/her first name and last name, and outputs the user's initials. -Refer to Problem Ch 03-1. Write a method to extract the initial from the first name.

(Short Answer)
4.8/5
(46)

Consider the condition (x == y). How is this handled if x and y are primitive types? How is this handled if x and y are objects?

(Essay)
5.0/5
(45)

What is a wrapper class? Why are wrapper classes useful?

(Essay)
4.7/5
(39)

In the StringMutation program shown in Listing 3.1, if phrase is initialized to "Einstein", what will Mutation # 3 yield if mutation1 = phrase.concat(".")?

(Multiple Choice)
4.9/5
(34)

Which properties are true of String objects?

(Multiple Choice)
4.9/5
(35)

What will be displayed by the following command? System.out.println(Math.pow(3, 3-1));

(Multiple Choice)
4.8/5
(33)
Showing 21 - 40 of 49
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)