Presentation is loading. Please wait.

Presentation is loading. Please wait.

AP Java String Review Learning Objectives

Similar presentations


Presentation on theme: "AP Java String Review Learning Objectives"— Presentation transcript:

1 AP Java String Review Learning Objectives
Review String Methods with Sample Mult Choice Problems Write programs incorporating String methods.

2 Part 1 4.) int v = x.compareTo ("apple"); a. v = positive 1 b. v = 0 c. v = negative 1 d .none of the above 5.) int k = x.compareTo("Hello"); a. k = 0 b. k = negative 1 c. k = positive 1 d. none of the above 6.) String t = x.substring ("Hell"); a. Error b. 0 c. 1 d. 2 7.) String t = x.substring(2); a. t is "lo" b. t is "ello" c. t is "Hello" d. t is "llo" String x = "Hello"; 1.) int y = x.length(); a. x = 3 b. x = 2 c. x = 5 d. x = ) int z = x.indexOf ("ll"); a. z = 3 b. z = 2 c. z = 4 d. z = ) int w = x.indexOf("he"); a. w = 1 b. w = -1 c. w = 2 d. w = 0 8.) String b = x.substring(2, 4); a. b is "llo" b. b is "ell" c. b is "ll" d. b is "el" 9.) int c = x.length; a. 2 b.3 c.4 d. Error ) String u = x.substring (2, 3); a. error b. u is " l " c. u is "el " d. u is " ell " ) int w = x.equals("ELLO"); a.True b.False ) int a = x.substring(3); a. a is "lo" b. a is "llo" c. a is "ello" d. error

3 7. ) String c = x. substring(4). substring(5); a. c= LIAM_COUNTY b
7.) String c = x.substring(4).substring(5); a. c= LIAM_COUNTY b. c= CEWILLIAM_COUNTY c. c = _COUNTY d. c = ILLIAM_COUNTY 8.) int j = x.indexOf ("WILLIaM"); a. j = 6 b. j = 5 c. j = 4 d. j = ) int y = x.equals("PRINCEWILLIAM_COUNTY"); a.True b.False c. error ) int z = x.indexOf ("PRIN"); a. z = 0 b. z = 1 c. z = -1 d. z = ) String a = x.substring("2,8"); a. INCEWI b. RINCEWI c. INCEWIL d. error Part 2 String x = "PRINCEWILLIAM_COUNTY" 1.) int y = x. length (); a. 20 b. 21 c. 19 d ) int t = x.indexOf (PRIN); a. t = 0 b. t = 1 c. t = 2 d. Error 3.) String k = x.substring (2); a. k = RINCEWILLIAMCOUNTY b.k = RINCEWILLIAM_COUNTY c. k = INCEWILLIAM_COUNTY d.none of the above 4.) String q = x.substring(5, 17); a. q = CEWILLIAM_COUNT b. q = EWILLIAMCOUN c. q = EWILLIAM_COU d. q = CEWILLIAM_COUN 5.) int u = x.compareTo ("STRINGS"); a. negative 1 b. positive 1 c. 0 d. none of the above 6.) String g = x.substring("COUN"); a. g = 14 b. g = 13 c. Error d. g = 13

4 String Program Options
Complete any Two of the following. String Program Options Find last name Input first and last name into one String Output only the last name. Push: Support middle names Write a mad-lib program Have the user enter at least 4 pieces of information. Noun, Adverb (honestly), Adjective (messy), Verb, Geographical location, … The computer will generate the mad-lib English to Pig-Latin translation program. The rules of Pig Latin are If the word begins with a consonant -- such as ``string,'' ``Latin'' -- divide the word at the first vowel, swapping the front and back halves and append ``ay'' to the word -- ``ingstray,'' ``atinLay.'' If the word begins with a vowel -- such as ``am,'' ``are,'' ``i'' -- append ``yay'' to the word -- ``amyay,'' ``areyay,'' ``iyay.'' If the word has no vowels (other than 'y') -- such as ``my,'' ``thy'' -- append ``yay'' to it -- ``myyay,'' ``thyyay.'' Level 1, Translate a single word Level 2: Translate a sentence. Input a word, output whether or not it is a palindrome.


Download ppt "AP Java String Review Learning Objectives"

Similar presentations


Ads by Google