0% 0 votes, 0 avg 23 1234567891011121314151617181920 This quiz randomly generates 20 questions as asked in AP Computer Science A (AP CSA) - Programming in Java. Congratulations! AP Computer Science A (AP CSA) - Programming in Java This quiz randomly generates 20 questions (in 30 mins) as asked in AP Computer Science A (AP CSA) - Programming in Java. 1 / 20 What is the output? A B B A A Null Pointer Exception is thrown at runtime. A 0 B 1 2 / 20 Question The method reduce() is not a public method because methods whose return type is void cannot be public. methods that change this cannot be public the reduce() method is not intended for use by clients of the Rational class. the reduce() method is intended for use only by clients of the Rational class. the reduce() method uses only the private data fields of the Rational class. 3 / 20 A programmer is designing a program to catalog all books in a library. He plans to have a Book class that stores features of each book: author, title, isOnShelf and so on, with operations like getAuthor, getTitle, getShelfInfo, and setShelfInfo. Another class, LibraryList, will store an array of Book objects. The LibraryList class will include operations such as listAllBooks, addBook, removeBook, and searchForBook. The programmer plans to implement and test the Book class first, before implementing the LibraryList class. The programmer's plan to write the Book class first is an example of top-down development. bottom-up development. procedural abstraction. information hiding. a driver program. The programmer is using an object-oriented approach to writing the program and plans to test the simplest classes first. This is bottom-up development. In top down development (choice A), high-level classes are broken down into subsidiary classes. Procedural abstraction (choice C) is the use of helper methods in a class. Information hiding (choice D) is restriction of access to private data and methods in a class. Choice E is wrong because a driver program is one whose sole purpose is to test a given method or class. Implementing the simplest classes hrst may involve driver programs that test the various methods, but the overall plan is not an example of a driver program. 4 / 20 Refer to the following code fragment: double answer = (double) 13 / 5; double answer = 13 / (double) 5; double answer = 13.0 / 5; double answer = 13 / 5.0; double answer = (double) (13 / 5); 5 / 20 Question None I only II only III only I and II only 6 / 20 What is the output? 1:2:3:4:5: 1:2:3: Compilation fails An ArrayOutOfBoundsException is thrown at runtime Four words become HiHowAreYou, since its length is more than 4, nothing will be removed and HiHowAreYou removed will be printed. 7 / 20 What is the output? Compilation fails. The program compiles, but it prints nothing. HiHowAreYou removed An UnsupportedOperationException is thrown at runtime. 8 / 20 Question 74 47 734 743 347 9 / 20 Question r = a.plus(r); a = r. plus (new Rational (n)); r = r.plus(r); a = n. plus(r); r = r. plus (new Rational(n)); 10 / 20 What is the output? C B A C A B C Compilation fails at line n1 and line n2 11 / 20 Question Which of the following is a false statement about the methods? equals, lessThan, and toString are all accessor methods. increment is a mutator method. Time() is the default constructor. The Time class has two constructors. There are no static methods in this class. 12 / 20 Question Rational r1 = new Rational(); Rational r2 = r1; Rational r3 = new Rational (2,-3); Rational r4 = new Rational (3.5); Rational r5 = new Rational (10); 13 / 20 What is the output? An exception is thrown at runtime. 07-31-2014 2014-07-31 2014-09-30 14 / 20 The boolean expression !A && B || C is equivalent to !A && (B II C) ((!A) && B) II C (!A) && (B II C) !(A && B) II C !(A && B II C) 15 / 20 What is the output? Compilation fails at line n2. Compilation fails at line n1 20:20 10:20 16 / 20 Question I only II only III only I and II only I and III only 17 / 20 For the sample code: Consider this description of the Deck constructor: if (i / 13 == 1) myDeck [i / 13] = new Card("hearts", i % 13); i f (i >= 13 && i <= 25) myDeck [i % 13] = new Card("hearts", i % 13); i f ( i / 13 == 1) myDeck [i] = new Card("hearts", i % 13); i f (i >= 13 && i <= 25) myDeck [i] = new Card("hearts", i / 13); i f (i / 13 == 1) myDeck [i % 13] = new Card("hearts", i % 13); 18 / 20 Question Round-off eror was caused by calculations with floating-point numbers. Type boolean was not recognized by an obsolete version of Java. An overflow error was caused by entering numbers that were too large. c and d should have been cast to integers before testing for equality. Bad test data were selected. 19 / 20 What is the output? 1 2 3 0 01 2 3 0 0 An Exception is thrown at run time. 1 2 3 0 01 2 3 1 2 31 2 3 20 / 20 Which code fragment, when inserted at line 6, enables the code to print true? String str2 = str1; String str2 = new String(str1); String str2 = sb1.toString(); String str2 = "Duke"; Your score is 0% Restart quiz