COMP1210 Test 1 (Cross)
x and y are variables that refer to the same object
If x and y are aliases of each other with respect to reference types in Java, then
semantics
"meaning"; what a given legal structure in the language means
local data
(declared inside of a method); can only be used within that method
instance data
(fields declared at the top of the class); can be referenced by all methods in that class
support, service
A private method is referred to as a ________ method, while a public method is referred to as a _______ method.
string literal
A string of characters can be represented as a _________ by putting double quotes around the text.
scope
A variable's _______ is determined by where it is declared.
instance
An object is an _____ of some particular class.
the main method of your class
Executed first when you run your Java application
2^10
How many unique items can be represented by 10 bits?
instance variables, methods
In object oriented programming, the ______ of the class define the state of an object (or instance) of the class, whereas the _________ of the class define the behavior of an object (or instance) of the class.
private
Instance variables should be declared with what type of visibility to promote encapsulation?
strongly typed
Java is __________, so in an assignment statement, the type of the variable on the left and the type of the result of the expression on the right must be compatible
true
Java is a high-level, compiled, object oriented programming language.
false
Java is interpreted, but not compiled.
Sun Microsystems
Java was developed by ______.
inheritance
New classes are derived from existing ones through ________.
programming language
Specifies the words and symbols that we can use to write a program
private, public
Well encapsulated classes have _____ variables and _______ methods.
instance data
When an object is created, spaced is reserved in memory for that object's _______.
False
when the new operator creates an object, a destructor with the same name as the class is invoked to help set it up initially
java.lang
Which Java Class Library is imported automatically?
Java bytecode, Java source code
______ is created by the Java compiler based on the ________.`
mutator, state
_______ method changes the _______ of the object
false
a private method can be invoked outside the class since it helps the other methods of the class do their job
aliases
when two or more references refer to the same object
true
a string object is immutable meaning the object cannot be changed in memory once it has been created
reserved
word in programming languages that is set aside for special purposes
if statement
allows a program to execute a statement or block {} only under certain conditions
if-else statement
allows a program to execute one statement or block {} for a true condition and a different statement or block {} for a false condition
character set
an ordered list of characters, and character represents a unique number
autoboxing
automatic conversion of a primitive value to a corresponding wrapper object
method header
begins method declaration with formal parameters
mutator method
changes the value of a variable; "setter"
UML
class diagrams that show relationships among classes in the program
NumberFormat
class that formats values as currency or percentages
DecimalFormat
class that formats values based on a pattern
Wrapper
class that provides the object equivalent of a primitive type
compile-time errors
compilation cannot be completed because of syntax errors or static semantic errors
arithmetic expressions
compute numeric results and make use of arithmetic operators
expression
construct made up of one or more variables, operators, and method invocations that evaluates to a single value
class
contains zero or more data and/or methods
method
contains zero or more local data and/or program statements that form an algorithm
actual parameters
copied into the formal parameters when the method is called
instantiation
creating an object
support methods
declared as private and can only be used by other methods in the class
access modifiers
define who can access an instance variable or method
reference variables
don't hold the object, but hold a memory location where the object is stored
scope
enclosing context in a program where that data can be referenced
assignment statement
example: myVar = 7;
escape sequences
examples: \t, \\, \", \n
run-time errors
execution is halted abnormally (deep end, crash, blow up, crash and burn)
logical errors
execution proceeds and halts normally, but incorrect behavior or incorrect results are observed
method body
follows the method header; created each time the method is called, and is destroyed with it finishes executing
widening conversions
go from a smaller to larger data type
narrowing conversions
go from large data type to a smaller one; you may lose data
algorithm
implemente by the instructions in the methods of a program
byte, short, int, long
increasing range of values for integer types
return type
indicates the type of value that the method sends back to the calling location
IDE (integrated development environment)
jGRASP is an example of an ________
program
made up of one or more classes
public
members of a class can be referenced anywhere
private
members of a class can only be referenced within that class
static
modifier allows it to be shard among all methods in the class
final
modifier prevents the initial value from changing
variable
name for a "location" in memory that holds program data
String
not a primitive type in Java
encapsulation
object thought of as a "black box"; its inner workings are hidden from the client
8
one byte has ___ bits
new
operator is used to create an object
syntax
set of rules that dictate how the words and symbols can be put together to form valid program statements; "grammar"
class libraries
sets of classes designed to be reusable components whose services can be used by many programs.
formal parameters
parameters in the method header
constant
placed at the class level (above the main method), written in all CAPS with underscores, and its initial value cannot be changed
println
prints a character string and then advances to the next line
object oriented programming
programming world-view in which things in the real world are modeled as software objects
service methods
public methods that offer useful behaviors to the client
boolean
represents a true or false condition
java.exe
represents the Java interpreter on your computer and is responsible for running your Java program
toString
returns a String that represents the object in some way
void
returns no value
accessor method
returns the current value of a variable; "getter"
coding standard
rules as to how source code should be formatted - makes code easier to read and debug
Java Class Library (JCL)
set of classes that are part of the JDK and documented in the Java API
method declaration
specifies the code that will be executed when the method is invoked
method header and method body
the two physical parts of a method are commonly called
public static void
the words required at the start of every "main" method definition
true
true or false: You find errors by testing and removing the discovered errors by debugging
white space
used to separate the elements (tokens) of the input; includes space characters, tabs, new line characters
constructor
used with the new operate to create an object and set its initial state. It looks similar to a method but has the same name as the class and has no return type
char
variable that stores a single character