AP CSA Unit 2: Lesson 4 Questions

studied byStudied by 6 people
0.0(0)
Get a hint
Hint

Suppose the String s is declared and initialized as follows: String s = "elementary"; What String would be returned by the method call s.substring(1, 4);?

1 / 9

flashcard set

Earn XP

Description and Tags

10 Terms

1

Suppose the String s is declared and initialized as follows: String s = "elementary"; What String would be returned by the method call s.substring(1, 4);?

lem

New cards
2

What will be printed by the following code? String s = "Animal"; System.out.println(s.indexOf("al"));

4

New cards
3

Suppose s1 and s2 are Strings and the following code is run: s1 = s1.toLowerCase(); s2 = s1.toUpperCase(); System.out.println(s1.compareTo(s2)); What should be the expected output?

A positive value is printed

New cards
4

Which of the following correctly declares a new variable which can be used to point to an object of the double class type?

double d;

New cards
5

Which of the following best describes the relationship between a class and an object?

Objects are created using classes, which are similar to blueprints.

New cards
6

Select all the classes from the list

Scanner String

New cards
7

Which code shows us creating an object of data type Scanner class and storing it with a variable named stat ?

Scanner stat = new Scanner(System.in);

New cards
8

How would you make int a class?

Use Integer

New cards
9

What will be printed by the following code? String s = "Tiny"; System.out.println(s.indexOf("n"));

2

New cards
10

Suppose the String s is declared and initialized as follows: String s = "middle"; What String would be returned by the method call s.substring(3, 4);?

d

New cards

Explore top notes

note Note
studied byStudied by 23 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 41 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 11 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 46 people
Updated ... ago
4.0 Stars(1)
note Note
studied byStudied by 91 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 26 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 30060 people
Updated ... ago
4.4 Stars(24)

Explore top flashcards

flashcards Flashcard36 terms
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard117 terms
studied byStudied by 66 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard27 terms
studied byStudied by 16 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard103 terms
studied byStudied by 16 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard47 terms
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard29 terms
studied byStudied by 15 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard46 terms
studied byStudied by 4 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard40 terms
studied byStudied by 65 people
Updated ... ago
5.0 Stars(1)