Solutions!!
1. A java application
always contains a main
single method, public static void main(String[] args)
this method is
called?
Give the
signature of
this method.
2. How is data given to Through a command line interface. For example: java
someCompiledClass data
this parameter?
3. Identifiers can
only begin with? Letters, underscores, dollar sign
4. Is Java a Func-
tional Language, Object-Oriented
Procedural Lan-
guage, Object-Ori-
ented Language,
or
Logic Language?
5. What does
API stand
for?
Application Programmer Interface
6. What needs to
be done to use
the scanner
class? import java.util.Scanner;
7. What's the dif-
ference
between
println, and println ends with a line break
1/
9
, CSE 205 Exam 1 Questions And Answers With Verified
Solutions!!
8. What is The hiding of design decisions in a computer program that are most
Encapsula- tion?
likely to change, thus protecting other parts of the program from
change if the design decision is changed.
The variables contained in an object should be modified only within the
9. What are the
three visibility object
modifiers and
what is their public: can be accessed from anywhere
scope? private: can only be accessed from inside the class
protected: the member can only be accessed within its own package
(as with package-private) and, in addition, by a subclass of its class in
another package.
10. What is the purpose The purpose is to give a readable representation of the object.
of toString()?
11. What is an accessor An accessor method can be defined to access private variable in the
class
method? since private data cannot be accessed from outside of the class.
12. What is mutator method can be defined to modify private variable in the class.
mutator
method?
13. What is a constructor is a special method that is used to create a new object.
construc- tor?
14. Define a
construc- tor with Point(int x, int y){ this.x = x; this.y = y;}
public
two para- meters
int x, y for the
class Point.
15. Which method
sig- public int calc(int num1, int num2){ ... }
natures
would give an public double calc(int num1, int num2){
error if all meth-
...}
dittering return type is not enough, must ditter in parameter types
2/
9