U2Q

pdf

School

Rowan College, Burlington County *

*We aren’t endorsed by this school

Course

111

Subject

Computer Science

Date

Dec 6, 2023

Type

pdf

Pages

5

Uploaded by MagistrateDiscoveryKangaroo81

Report
10/1/21, 8:07 AM Quiz: Unit 2 Quiz https://courses.projectstem.org/courses/10083/quizzes/220993/take 1/5 Unit 2 Quiz Started: Oct 1 at 8:07am Quiz Instructions 1 pts Question 1 Hello, \n\tWorld Hello, World Hello, World Hello, World Hello, World What is output by the following code? System.out.println("Hello, \n\tWorld"); 1 pts Question 2 "o" 'om' The call causes an error Consider the following code: String major = "Computer Science"; What is returned by the method call major.substring(1, 2) ?
10/1/21, 8:07 AM Quiz: Unit 2 Quiz https://courses.projectstem.org/courses/10083/quizzes/220993/take 2/5 "C" "Co" 1 pts Question 3 void class reference garbage collection null A special value that means "no object" is called ______. 1 pts Question 4 Sum=45 Sum=54 Sum= 5 4 Sum=4 5 Sum=9 What is output to the screen by the following code? System.out.println("Sum=" + 4 + 5); 1 pts Question 5
10/1/21, 8:07 AM Quiz: Unit 2 Quiz https://courses.projectstem.org/courses/10083/quizzes/220993/take 3/5 Classes and object are the same exact thing and the terms can be used interchangeably. A class is an instance of an object. Objects only contain one piece of data Object variables have a reference pointing to their location in memory. It is possible to have many classes of the same object. Which of the following is true about classes and objects? 1 pts Question 6 None of the calls shown will cause an error All the calls shown will cause an error s.substring(0) s.substring(4, 5) s.substring(0, 5) Suppose s is a String which contains 5 characters. Which of the following calls will cause an error? 1 pts Question 7 rk What does the following code do? String w3 = "aardvark"; System.out.println(w3.substring(w3.length()-2));
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
10/1/21, 8:07 AM Quiz: Unit 2 Quiz https://courses.projectstem.org/courses/10083/quizzes/220993/take 4/5 Causes an index out of bounds error. aardvak k ardvark 1 pts Question 8 void int private return new What keyword is used in order to build an object in memory of any data type (String, Scanner, etc)? 1 pts Question 9 banana anachronism advance meaning Suppose s is a string, and that the call s.indexOf("an") returns 3. Which of the following could be the value of s?
10/1/21, 8:07 AM Quiz: Unit 2 Quiz https://courses.projectstem.org/courses/10083/quizzes/220993/take 5/5 Not saved breathing 1 pts Question 10 c.compareTo(c) It is not possible for the compareTo method to return a negative number a.compareTo(b) a.compareTo(c) b.compareTo(a) Suppose three strings are declared and initialized as shown below. String a = "lizard"; String b = "chameleon"; String c = "lizard"; Which of the following calls to the compareTo method will return a negative number? Submit Quiz