Search Header Logo
Strings and Class Type

Strings and Class Type

Assessment

Presentation

Computers

10th - 12th Grade

Medium

Created by

Alexandra Ulrich

Used 18+ times

FREE Resource

8 Slides • 5 Questions

1

Strings and Class Type

AP CSA

media

2

Class data types are capitalized, and primitive data types are not

Primitive data types only hold one piece of data at a time





3

Multiple Choice

int x=15; is :

1

primitive type

2

class type

4

Multiple Choice

True or False: Variables of class data types do not always have to hold a memory location all the time

1

True

2

False

5

When a group of statements, including control structures are assembled into a single unit, the unit is called a class

Naming conventions are similar to those of a variable but a class should begin with a capital letter and reference the purpose of the class.

public class GradePointAvg

{

// statements not shown

}

6

Multiple Choice

Which of the following class declarations would cause a compile-time error? Assume the rest of the code compiles as intended.

1

public class Science

2

public class apScience

3

public class APScience

4

public class 4APScience

5

public class APScience extends Science

7

A Java string is a series of characters gathered together, like the word "Hello", or the phrase The expert in anything was once a beginner — Helen Hayes.

8

The standard way to create a new object of a class in Java:

greeting = new String("Hello");


You can also use just a string literal, which is a set of characters enclosed in double quotes ("), to create a String object.

greeting = "Hello";

9

Strings can be appended to each other to create a new string using the + or += operator .

This is also called concatenation.

  String start = "Happy Birthday";

    String name = "Jose";

    String result = start + " " + name; // add together strings

10

Multiple Choice

Which of the following statements use string literal?

1

System.out.print(side1);

2

System.out.print("side1");

11

Numerical values can be printed to the screen for output

  • Example: If a triangle has a side length of 2 stored in memory using identifies side1 and you eant to ouput that information to the screen you could use either:

  • System.out.print(2);

  • System.out.print(side1): //will display the value stored using the side1 identifier

  • System.out.print("side 1") // will display

12

Multiple Choice

Assuming all other statements in the program are correct, each of the following statements will allow the program to compile EXCEPT:

1

System.out.print(2);

2

System.out.print("2");

3

System.out.print(side1);

4

System.out.print("side1");

13

Don't forget to look at activites on coding bat for addtional practice.

(6 min)

https://codingbat.com/doc/java-string-introduction.html

https://youtu.be/xqFGn5P1Ho8

Strings and Class Type

AP CSA

media

Show answer

Auto Play

Slide 1 / 13

SLIDE