Posts

Showing posts with the label Introduction to Java

CS3401 Practice Quiz 2 Part 2

Image
Introduction to Java Programming Introduction to Java Programming, Ninth Edition, Y. Daniel Liang Chapter 10 Thinking in Objects Please send suggestions and errata to Dr. Liang at y.daniel.liang@gmail.com . Indicate which book and edition you are using. Thanks! Section 10.2 Immutable Objects and Classes 10.1   Which of the following statements are true about an immutable object? A. The contents of an immutable object cannot be modified. B. All properties of an immutable object must be private. C. All properties of an immutable object must be of primitive types. D. An object type property in an immutable object must also be immutable. E. An immutable object contains no mutator methods. Your answer is correct Section 10.3 Scope of Variables 10.2   What is the printout for the first statement in the main method? public class Foo {   static int i = 0;   static int j = 0;  ...

CS3401 Practice Quiz 2 Part 1

Image
Introduction to Java Programming Introduction to Java Programming, Ninth Edition, Y. Daniel Liang Chapter 21 Generics Please send suggestions and errata to Dr. Liang at y.daniel.liang@gmail.com . Indicate which book and edition you are using. Thanks! Section 21.2 Motivations and Benefits 21.1   Which of the following statements is correct? A. Generics can help detect type errors at compile time, thus make programs more robust. B. Generics can make programs easy to read. C. Generics can avoid cumbersome castings. D. Generics can make programs run faster. Your answer is correct 21.2   Fill in the code in Comparable______ c = new Date(); A. <String> B. <?> C. <Date> D. <E> Your answer is correct 21.3   Which of the following statements is correct? A. Comparable<String> c = new String("abc"); B. Comparable<String> c = "abc"; C. Compa...