Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pre-AP® Computer Science Quiz

Similar presentations


Presentation on theme: "Pre-AP® Computer Science Quiz"— Presentation transcript:

1 Pre-AP® Computer Science Quiz 12.01- 07
Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have at least 20 seconds for each question.

2 Title the quiz as shown below The quiz starts in ONE minute.
Name Period Date Quiz EC.

3 Question 01 Which of the following is actually a class? int double
char boolean String

4 Question 02 Which of the following is a set of characters that behave as a single unit? int double char boolean String

5 Question 03 The characters in a String can include Upper-case letters
Lower-case letters Numerical digits Symbols like # $ % ^ & * ( ) _ + All of the above

6 Question 04 True or False In Java, a String is really just an
array of characters. (a) True (b) False

7 Question 05 Consider this Java statement: String name = “John”;
Which of the following is the string variable? String name “John”

8 Question 06 Consider this Java statement: String name = “John”;
Which of the following is the string literal? String name “John”

9 Question 07 Which of the following constructs a String object?
String s1 = "Aardvark"; String s2 = new String( ); s2 = "Aardvark"; String s3 = new String("Aardvark"); String s4 = new String(s3); char animal[ ] = {'A', 'a', 'r', 'd', 'v', 'a', 'r', 'k'}; String s5 = new String(animal); All of the above

10 Question 08 With String, the plus [ + ] and
plus-equals [ += ] operators perform addition. subtraction. multiplication. division. concatenation.

11 Question 09 Which String method allows access to an individual character in a String object? (a) indexOf (b) charAt (c) length (d) replace (e) lastIndexOf (f) valueOf

12 Question 10 Which String method allows you to access the “tan" in "Standard“? (a) indexOf (b) charAt (c) length (d) replace (e) substring (f) valueOf

13 Question 11 Which String method allows you find the location of the “tan" in "Standard". (a) indexOf (b) charAt (c) length (d) replace (e) substring (f) valueOf

14 Question 12 Which String method returns the number of characters in the String? (a) indexOf (b) charAt (c) length (d) replace (e) substring (f) valueOf

15 Question 13 Which String method replaces all occurrences of one character with another? (a) indexOf (b) charAt (c) length (d) replace (e) substring (f) valueOf

16 Question 14 Which String method converts primitive data type values to String values? (a) indexOf (b) charAt (c) length (d) replace (e) substring (f) valueOf

17 Question 15 Which String method has the same name as a field from a Java static array ? (a) indexOf (b) charAt (c) length (d) replace (e) substring (f) valueOf

18 Question 16 Which of the following string literals would NOT be affected by either String methods toUpperCase or toLowerCase? John Smith </*{-(12345)-}*\> Hello123 QWERTY is

19 Question 17 If x and y are simple/primitive data types, and you need to check if they are equal, which command would you use? if ( x = y ) if ( x == y ) if ( x != y ) if ( x.equals(y) ) if ( !x.equals(y) )

20 Question 18 If x and y are String objects, and you need to check if they are equal, which command would you use? if ( x = y ) if ( x == y ) if ( x != y ) if ( x.equals(y) ) if ( !x.equals(y) )

21 Question 19 Which values of s1 and s2 will cause these 2 statements to display different outputs? System.out.println(s1.indexOf(s2)); System.out.println(s1.lastIndexOf(s2)); s1 = “Texas”; s2 = “Tex”; s1 = “Mississippi”; s2 = “iss”; s1 = “Utah”; s2 = “ah”; s1 = “Tennessee”; s2 = “qwerty”;

22 Question 20 True or False All of the methods of the String
class are object methods. (a) True (b) False

23 Question 21 String animal = "Giraffe";
What is the output of the program segment below? String animal = "Giraffe"; String s = animal.substring(1,3); System.out.println(s); Gir (b) ira (c) Gi (d) ir

24 Extra Credit Assume s stores “Hello, I live at 123 Baker St.”
Which program statement alters the value of the String object s. (a) s.substring(7,13); (b) s.replace('l','w'); (c) s.toUpperCase(); (d) s.toLowerCase(); (e) All of the above (f) None of the above


Download ppt "Pre-AP® Computer Science Quiz"

Similar presentations


Ads by Google