int x = 5/10
What is stored in x?
0
"rachmaninoff".length()
12
int x = Math.random();
What is x?
0
Explain what a static method is.
A static method is a method that is not invoked from an object (and thus, does not use any instance variables).
double x = 5/10;
What is stored in x?
0.0
What is the result of
"rachmaninoff".substring(0)
"rachmaninoff"
double x = (int) Math.random();
What is x?
0.0
A Building class has an empty (null) constructor. Write the header for the empty constructor
public Building()
double x = (double) 5/10;
What is stored in x?
0.5
What is the result of
String x = "hello";
x + x.substring(x.length() - 1);
"helloo"
double x = Math.random() - Math.random();
What is the smallest possible value of x?
-1.0 (not including)
A Person object consists of a name (String) and an age (int). Write an accessor method for the name instance variable.
public String getName()
{ return this.name;}
What is stored in x?
What is the result of
"AP Computer Science".substring(5,6);
"m"
int x = (int) 5*Math.random();
What is the largest possible value of x?
4
A Person object consists of a name (String) and an age (int). Write an appropriate constructor for the Person class that fills in the instance variables.
int x = 11 % 3;
What is stored in x?
String s = "ap-cs-a";
int i = s.indexOf("-");
s = s.substring(0,i) + s.substring(i+1);
What is stored in variable 's'?
"apcs-a"
int x = 10*((int) Math.random()) + 5;
What is x?
5
A Student consists of a name "String" and a grade level (int). A Group consists of two Student objects s1 and s2. Write a Group constructor that takes in a name and a grade for each Student (4 arguments total), constructs two Students, and assigns them to the Group instance variables s1 and s2.
public Group(String n1, int g1, String n2, int g2)
{
this.s1 = new Student(n1, g1);
this.s2 = new Student(n2, g2);
}