Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. What is the value of number after the following code is executed? String str1 = summer; String str2 = fun; int value = str2.compareTo(str1);

1. What is the value of number after the following code is executed? String str1 = "summer"; String str2 = "fun"; int value = str2.compareTo(str1);

A)1

B)0

C)1

D)A positive integer

E)A negative integer

2. Which standard Java interface allows you to determine if two Strings are in lexicographical order?

A)Iterable

B)Comparable

C)Incrementable

D)Sortable

E)Searchable

3. What is wrong with the following line of code found within a concrete class? Comparable comp = new Comparable

A)An abstract class cannot be instantiated.

B)A concrete class cannot be instantiated.

C)An interface cannot be instantiated.

D)A specific type for T must be provided.

E)Nothing is wrong with this line of code.

4. Which of the following statements is true?

  1. A class can implement only one interface.
  2. A class can extend a concrete class.
  3. A class can extend only one class.

A)I only

B)II only

C)III only

D)I and II only

E)II and III only

5. Which of the following CANNOT be instantiated?

  1. a concrete class
  2. an abstract class
  3. an interface

A)I only

B)II only

C)III only

D)I and II only

E)II and III only

6. Consider the following incomplete classes: public abstract class MyClass { public void method1(int x) { // implementation not shown } public abstract void method2(int y); } public interface MyInterface { public void method3(int z); } Which of the following methods must be defined in a class that implements MyInterface?

  1. method1
  2. method2
  3. method3

A)I only

B)II only

C)III only

D)I and II only

E)II and III only

7. Consider the following code: String value1; String value2; // assume other code not shown // value1 and value2 are initialized with valid Strings if ( < some code here> ) { System.out.println("value2 comes before value1 in the dictionary"); } else { System.out.println("value1 comes before value2 in the dictionary, or they are the same"); } Which of the following could be used to replace < some code here>?

A)value1 < value2

B)value2 < value1

C)value1.compareTo(value2) < 0

D)value2.compareTo(value1) < 0

E)value1.compareTo(value2) == 0

8. Which of the following statement about interfaces is true?

  1. An interface only contains public abstract methods and public static final variables.
  2. If a class implements an interface but fails to implement its methods, then the class must be declared to be abstract.
  3. A class may extend only one class, but it may implement multiple interface.

A)I only

B)II only

C)III only

D)II and III only

E)I, II, and III

9. Consider the following code: public class Shape { private SomePoint myPosition; public Shape( SomePoint position ) { myPosition = position; } public abstract void draw(); public void moveTo( SomePoint p ) { myPosition = p; draw(); } } The code will not compile. Which of the following eliminates the error?

  1. public abstract Shape( SomePoint position )
  2. public abstract class Shape
  3. private abstract SomePoint myPosition;

A)I only

B)II only

C)III only

D)I and II only

E)I and III only

10. Which of the following statements about classes and interfaces is true?

  1. An abstract class and interface may implement methods.
  2. A class may implement many interfaces but has only one superclass.
  3. Many different classes can implement the same interface.

A)I only

B)II only

C)I and II only

D)II and III only

E)I, II, and III

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_2

Step: 3

blur-text-image_3

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

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions