Exam 1 Flashcards
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
Number variables actually ____________
Store numbers
When you copy a number, the original and the copy of the number are _______________
Independent values
When you copy an object reference both the original and the copy are references to the _________
Same object
Start the comment with a
/**
Omit _______ tag for methods that have no arguments
@param
Omit the _________ tag for methods whose return type is void
@return
End a comment with
*/
API
Application programming interface
Lists classes and methods of the java library
API documentation
A programmer who uses the java classes to put together a computer program (or application)
Application programmer
A programmer who designs and implements library classes such as PrintStream and Rectangle
Systems programmer
Once you create your own _________, you can no longer use Java’s default constructor
This is true whether you create a ___________ constructor, and _________ constructor, both types, of more than 2 constructors
Constructor
No-argument
Argument
_______________ store data of an object
Instance variable
_____________ is an object of the class
Instance of a class
An ____________ is a storage location in each object created from a class
Instance variable