Exam 1 Flashcards
(98 cards)
public class HelloPrinter
What is the access specifier
public
public class HelloPrinter
What is the class keyword
class
public class HelloPrinter
What is the class name
HelloPrinter
What is the code to create a main Method
public static void main(String[] args)
{
}
public static void main(String[] args)
{
}
What is the access specifier
public
public static void main(String[] args)
{
}
What is the return type
void
public static void main(String[] args)
{
}
What is the method name
main
public static void main(String[] args)
{
}
What is the parameter
(String[] args)
Scanner class can be used for input from the ___________
Keyboard
What’s the code to import a scanner class
import java.util.Scanner;
Code to declare a scanner object
Scanner scan = new Scanner(System.in);
Name the scanner methods
nextLine()
nextInt()
nextDouble()
No nextbooleans or nextchar
A class describes a set of objects with the _______ behavior
Same
Which of the following are legal identifiers?
Greeting1 g void 101dalmations Hello, World
Only the first two
What is the output:
String greeting = “Hello, World!”;
System.out.println(greeting.length());
13
________ method replaces ALL instances of a substring in a string with a new substring
replace
What is the output
String river = “Mississippi”;
river = river.replace(“issipp”, “our”);
System.out.println(river);
Missouri
String river = “Mississippi”;
Is it legal to call river.println(); ? Why or why not?
Not legal. Variable river has type string.
println method is not a method of the String class
What are the steps in writing a tester class
- Provide a tester class
- Supply a main method
- Inside the main method, construct one or more objects.
- Apply methods to the objects.
- Display the results of the methods calls.
- Display the values that you expect to get.
An ________________ is a variable whose data type is a class.
Object variable
An object variable does _____ actually hold and object.
Not
An object variation holds the ___________ of an object
Memory location
Multiple object variables can refer to the ________ object
Same
Numbers are _____ objects
Not