Verified
1. A java application always contains a single
method, this method is called? Give the main.
signature of this method. public static void
main(String[] args)
2. How is data given to [main] parameter? Through a command line
in-
terface. For example: java
someCompiledClass data
3. Identifiers can only begin with? Letters, underscores,
dollar sign
4. What does API stand for? Application Programmer
In- terface
5. What needs to be done to use the scanner class? import java.util.Scanner;
6. What's the difference between println, and print. println ends with a line
break
7. What is Encapsulation? The hiding of design de-
cisions in a computer
pro- gram that are most
likely to change, thus
protecting oth- er parts of
the program from change
if the design decision is
changed.
The variables contained in
an object should be
modified only within the
object
8. What is the purpose of toString()? The purpose is to give a
1/
19
,CSE 205 Final Review Questions And Answers |
Verified
read- able representation
of the ob- ject.
2/
19
, CSE 205 Final Review Questions And Answers |
Verified
9. What is an accessor method? AKA getter, an accessor
method can be defined to
ac- cess private variable
in the class since private
data cannot be accessed
from outside of the
class.
10. What is mutator method? A mutator method can be
de- fined to modify
private vari- able in the
class.
11. What is a constructor? A constructor is a special
method that is used to
create a new object.
12. Define a constructor with two parameters int x, y for public Point(int x, int y){
this.x
the class Point. = x; this.y = y;}
13. What is the difference between an instance variable, instance variables are
global
and a local variable? to all instance methods of the
class, local variables are
only visible to the method
scope in which its
14. The this reference refers to the instance of the defined.
ob- ject.
15. What is the keyword that associates a
variable or method with the class?
static
16. Do all classes need a main method? No, only one class
3/
19