AP CSA Unit 2: Objects

studied byStudied by 219 people
5.0(2)
get a hint
hint

object

1 / 15

Tags and Description

16 Terms

1

object

a data type that is created in Java

New cards
2

Math class

stores common numbers used in mathematical calculations and methods that have mathematical functions

New cards
3

static method

belong to a class but not to any instances of that specific class

can be called without class’s instance or object

New cards
4

Math.abs(x)

gets the absolute value of ‘x’ ; the return value is always positive

New cards
5

Math.pow(x,y)

does ‘x’ to the power of ‘y’ (x^y); the answer will always be a double(decimal) value

New cards
6

Math.PI

stores the value for pi: 3.141592653…

New cards
7

charAt(int x)

returns the char at the given index of ‘x’

New cards
8

contains(String s)

returns true when received string is within the called string, false otherwise

New cards
9

endsWith(String s)

returns true when received string ends with called string, false otherwise

New cards
10

equals(String s)

returns true when the two strings are equal, false otherwise

New cards
11

equalsIgnoreCase(String s)

returns true when the two strings are equal ignoring the case( lower or upper), false otherwise

New cards
12
public class Example{
public static void main(String[] args){
String s = "I like apples";
String g = "ILIKEAPPLES";
//What is returned from this line of code?
System.out.println(s.equals(g));
}
}

false

New cards
13
public class Example{
public static void main(String[] args){
String s = "I like apples";
String g = "ILIKEAPPLES";
//What is returned from this line of code?
System.out.println(toLowerCase(g));
}
}

ilikeapples

New cards
14
public class Example{
public static void main(String[] args){
int x = 2;
int y = 10;

int z = Math.pow(y,x);
System.out.println(z);
}
}

100.00

New cards
15
public class Example{
public static void main(String[] args){
int x = 2;
int y = -10.9;

int z = Math.abs(y);
//what is printed from this program
System.out.println(z);
}
}

10.9

New cards
16
public class Example{
public static void main(String[] args){
String hi = "hello, John Harvard";

//what is printed from this program?
System.out.println(hi.charAT(7));
}
}

J

New cards

Explore top notes

note Note
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 11 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 13 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 4 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 15 people
Updated ... ago
5.0 Stars(3)
note Note
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 3224 people
Updated ... ago
4.6 Stars(22)

Explore top flashcards

flashcards Flashcard57 terms
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard66 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard129 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard52 terms
studied byStudied by 2 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard39 terms
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard37 terms
studied byStudied by 31 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard58 terms
studied byStudied by 1335 people
Updated ... ago
5.0 Stars(10)
flashcards Flashcard48 terms
studied byStudied by 31 people
Updated ... ago
5.0 Stars(1)