Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Consider the expression: !((x > y) && (y y) || !(y y) && !(y ); rate2 = acct.getInterestRate(); // assignment 2 The reference to

1. Consider the expression: !((x > y) && (y <= 0)). It is equivalent to which of the following expressions?

  1. !(x > y) || !(y <= 0)
  2. !(x > y) && !(y <= 0)
  3. (x <= y) || (y > 0)

A)I only

B)II only

C)III only

D)I and III only

E)II and III only

2. Suppose a class named SportsCar is a subclass of a class called Automobile. Automobile has only two methods: accelerate and addGas. Which statement is true?

A)A SportsCar object has the methods accelerate and addGas only.No other methods are allowed, since no other methods are inherited.

B)A SportsCar object has at least the methods accelerate and addGas. It might add its own methods.

C)A SportsCar object has the methods accelerate and addGas only if it is cast to Automobile.

D)A SportsCar object has the methods accelerate and addGas only if they are static.

E)A SportsCar object has the methods accelerate and addGas only if they are abstract.

3. Which expression correctly determines that String s1 comes before String s2 in lexicographical order?

A)s1 < s2

B)s1 <= s2

C)s1.compareTo(s2) == 1

D)s2.compareTo(s1) < 0

E)s1.compareTo(s2) < 0

4. Which of the following sorting algorithms is written recursively?

A)Sequential

B)Binary

C)Selection

D)Insertion

E)Merge

5. What does overloading mean?

A)Defining a subclass method with an identical name, return type, and parameter list that is invoked instead of the parent class method

B)Defining a subclass method with an identical name and parameter list subclass that is invoked instead of the parent class method

C)Defining two or more methods in a class with the same name, return type, and parameter list, to perform functions that are slightly different from one another

D)Defining two or more methods in a class with the same name but different return types and parameter lists, to perform functions that are slightly different from one another

E)Defining two or more methods in a class with the same name but different parameter lists, to perform functions that are slightly different from one another

6. Assume a two-dimensional array is declared as follows: int arr[][] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; Which of these statements are true?

  1. arr.length is 3
  2. arr[0].length is 4
  3. arr[2][3] is 7

A)III only

B)I and II only

C)I and III only

D)II and III only

E)I, II, and III

7. Consider the following class descriptions and code. Account is an abstract class with one abstract method named getInterestRate. BasicCheckingAccount is a concrete class that extends Account. EnhancedCheckingAccount extends BasicCheckingAccount and overrides getInterestRate. Account acct; double rate1, rate2; acct = new BasicCheckingAccount(< parameters not shown >); rate1 = acct.getInterestRate(); // assignment 1 acct = new EnhancedCheckingAccount(< parameters not shown >); rate2 = acct.getInterestRate(); // assignment 2 The reference to getInterestRate in assignment 1 is to the class

A)Account

B)BasicCheckingAccount

C)EnhancedCheckingAccount

D)SavingsAccount

E)This cannot be determined by examining the code.

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

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions