CS300

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

4. What is the minimum number of objects that should be present in the heap-memory after the following line of code is run? String[] values = new String[] ["A", "B", null, "D", null, "F");

5

What is the minimum number of objects that should be present in the heap-memory after the following line of code is run? Integer[] data = new Integer[] [1, 2, new Integer(3), 4, new Integer(5));

6

Which of the following is TRUE about inheritance in Java? a. A subclass can extend zero or more parents, and can implement zero or more interfaces. b. A subclass can extend only one parent class and can implement only one interface. c. A subclass can extend a parent class or implement an interface, but not do both. d. A subclass can extend only one parent class and can implement zero or more interfaces.

A subclass can extend only one parent class and can implement zero or more interfaces.

True/False: A private method declared in a superclass can be overridden by a subclass.

False

True/False: An interface can contain signatures of private methods.

False

What does the following segment of code print out when it is run? String s = "John"; s.concat(" Doe"); System.out.println(s); a. John Doe b. Doe John c. JohnDoe d. John

John

public class Throwable extends Object public class Exception extends Throwable public class RuntimeException extends Exception public class RedException extends RuntimeException public class OrangeException extends RedException public class PurpleException extends Exception public class VioletException extends PurpleException According to the above "Reference Section", which of the following exceptions are checked exceptions?

PurpleException VioletException

public class Throwable extends Object public class Exception extends Throwable public class RuntimeException extends Exception public class RedException extends RuntimeException public class OrangeException extends RedException public class PurpleException extends Exception public class VioletException extends PurpleException According to the above "Reference Section", which of the following exceptions are unchecked exceptions?

RedException OrangeException RuntimeException

Is String a reference type?

Yes

What is the output of the following code? String s = null; boolean result = s.equals(""); System.out.println(result); a. true. Because s is null, it is empty and equals "" b. a NullPointerException because s is null.

a NullPointerException because s is null.

The following line of code represents an ________________ operation. Double x = 1.5; a. auto-boxing b. auto-unboxing

auto-boxing

2. The following line of code represents an ________________ operation. int x = new Integer(4);

auto-unboxing

What does the following code print when ran? String s = new String("abc"); String t = s; System.out.print(s==t);

true


Ensembles d'études connexes

Module 10 - The Employment Relationship

View Set

New York Permit Test Flash Cards

View Set

prepU ch 41 Management of Patients With Musculoskeletal Disorders

View Set

Anatomy Final: Aging, Senescence, and Death

View Set

CompTIA A+ Core 1 (220-1101) Certification Practice Exam

View Set

Public Playground Safety Handbook

View Set