Pre-AP® Computer Science Quiz

Slides:



Advertisements
Similar presentations
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 9 Strings.
Advertisements

String Processing Word processing term papers, writing memoirs, sending messages, responding to surveys, placing online orders and registering.
PreAP Computer Science Quiz
Chapter 7 Strings F To process strings using the String class, the StringBuffer class, and the StringTokenizer class. F To use the String class to process.
1 Working with String Duo Wei CS110A_ Empty Strings An empty string has no characters; its length is 0. Not to be confused with an uninitialized.
1 Strings and Text I/O. 2 Motivations Often you encounter the problems that involve string processing and file input and output. Suppose you need to write.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 8 Strings.
Java Programming Strings Chapter 7.
Strings An extension of types A class that encompasses a character array and provides many useful behaviors Chapter 9 Strings are IMMUTABLE.
Chapter 10 Review. Write a method that returns true is s1 and s2 end with the same character; otherwise return false. Sample Answer: public boolean lastChar(String.
Java Strings in 10 minutes
©2004 Brooks/Cole Chapter 7 Strings and Characters.
String class  Construct a string  String str = new String(“welcome”);  Char[] charr = {‘G’, ‘o’, ‘o’, ‘d’};  String mes = new String(charr);  A full.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 9: Characters * Character primitives * Character Wrapper class.
Strings In Java, strings are contained in an object that is an instance of the String class. String in java is the name of a class. That’s why it starts.
Fundamental Programming Structures in Java: Strings.
Introduction to Computers and Programming Strings Professor: Evan Korth New York University.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapters 3-4: Using Objects.
PreAP Computer Science Quiz
String Class in Java java.lang Class String java.lang.Object java.lang.String java.lang.Object We do not have to import the String class since it comes.
Characters The data type char represents a single character in Java. –Character values are written as a symbol: ‘a’, ‘)’, ‘%’, ‘A’, etc. –A char value.
PreAP Computer Science Quiz
PreAP Computer Science Review Quiz 08 Key
Java Overview. Comments in a Java Program Comments can be single line comments like C++ Example: //This is a Java Comment Comments can be spread over.
Chapter 7: Characters, Strings, and the StringBuilder.
String Definition A String is a set of characters that behaves as a single unit. The characters in a String include upper-case and lower-case letters,
String Definition A String is a set of characters that behaves as a single unit. The characters in a String include upper-case and lower-case letters,
String Processing Word processing term papers, writing memoirs, sending messages, responding to surveys, placing online orders and registering products.
Chapter 3A Strings. Using Predefined Classes & Methods in a Program To use a method you must know: 1.Name of class containing method (Math) 2.Name of.
Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 45 – 90 seconds per question. Determine the output.
String Definition A string is a set of characters that behaves as a single unit. The characters in a string include upper-case and lower- case letters,
PreAP Computer Science Quiz
Strings CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Declaring variables The type could be: int double char String name is anything you want like lowerCaseWord.
Strings A String is a sequence of letters
Java String Methods - Codehs
Take out a piece of paper and PEN. The quiz starts TWO minutes after the tardy bell rings. You will have 30 seconds per question. Exposure Java 2014 for.
Strings, Characters and Regular Expressions
Strings, StringBuilder, and Character
String class.
Multiple variables can be created in one declaration
String and String Buffers
Advanced Programming in Java
AP Java Unit 3 Strings & Arrays.
Chapter 7: Strings and Characters
MSIS 655 Advanced Business Applications Programming
Part a: Fundamentals & Class String
Chapter 9 Strings and Text I/O
Exposure Java 2015 Pre-AP®CS Edition Chapter 12 Slides String Methods
Pre-AP® Computer Science Quiz Key
Pre-AP® Computer Science Quiz
Take out a piece of paper and PEN.
PreAP Computer Science Review Quiz 08
PreAP Computer Science Quiz Key
String.
CS2011 Introduction to Programming I Strings
Take out a piece of paper and PEN.
PreAP Computer Science Quiz
Take out a piece of paper and PEN.
Take out a piece of paper and PEN.
Take out a piece of paper and PEN.
AP Computer Science DYRT Quiz
Take out a piece of paper and PEN.
STRINGS BY: DANIEL, JUSTIN, PANI.
Switch, Strings, and ArrayLists in Java
In Java, strings are objects that belong to class java.lang.String .
Strings in Java Strings in Java are also a reference type.
Unit-2 Objects and Classes
What We Want To Do User enters: Mary Smith
Presentation transcript:

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.

Title the quiz as shown below The quiz starts in ONE minute. Name Period Date Quiz 12.01-07 1. 12. 2. 13. 3. 14. 4. 15. 5. 16. 6. 17. 7. 18. 8. 19. 9. 20. 10. 21. 11. EC.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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) )

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) )

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”;

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

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

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