Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
135 Cards in this Set
- Front
- Back
What does "this" represent in getters and setters
|
Denotes a reference to an implicit Parameter and to call another constructor of the same class
|
|
A class typically contains what 3 things
|
fields for data
constructors to create objects methods getters and setters in that order |
|
What does the get method do
|
it only looks up the state of an object and reports on it
|
|
What does the set and add method do
|
modify the state of an object
|
|
What are methods that change instance fields called
|
mutator methods
|
|
What are methods that only access instance fields called
|
accessor methods
|
|
What is a class
|
A template or blueprint from which objects are made
|
|
What are you doing when you construct an object from a class
|
You have created an Instance of the class
|
|
What is encapsulation
|
Information hiding the implementation details from the user of an object
|
|
What is Inheritance |
When you extend an existing class that has all the properties of an existing class and adds more to it |
|
What is the data in an object called |
Instance Fields Or instance variables |
|
What are the procedures that operate on data called
|
Methods
|
|
What is the header of a class called MyProgram |
public class MyProgram{ } |
|
What does public mean |
It means its available to any other code in the program |
|
What does the reserved word void mean |
Indicates the method will not return a value |
|
When do you use the reserved word static |
When you want to keep track of some information shared by all the members of a class OR When it doesn't make sense to have more than one instance of a property or method |
|
What is an expression
|
A piece of code that evaluates to a single value like 2 + 2
|
|
What is a statement |
a full sentence that end with a semi-colon(;) For example: a = 3; Or System.out.println("Java"); |
|
How is encapsulation attained |
In the spirit of encapsulation it is common to make fields private. When instance data is private, that data can only be directly accessed from the that class. We still need access to these values however and that is done indirectly by adding public methods that obtain the field values for us. |
|
What do methods do |
They operate on objects and access their Instance Fields |
|
A method has two parameters and in dave.raisesalary(5) what are they called and which is which
|
dave is the Implicit Parameter and the number inside the parentheses is the Explicit Parameter
|
|
In every method what does the key word this imply |
That the word that follows is an implicit Parameter |
|
Does Math.pow(x , a) have an implicit parameter |
No because it does not use a math object to carry out its task. (It is a static method) |
|
What is Implicit in X.F(param) |
X is implicit and pram is explicit |
|
What are the 3 types of errors in programming |
Syntax errors Logical errors Runtime errors |
|
API
|
application program interface is a set of routines protocols and tools for building software applications. A good API makes it easier to develop a program by providing all the building blocks. A programmer then puts the blocks together.
|
|
Why is the header of a main method |
public static void main(String [] args){ } |
|
JVM
|
Java Virtual Machine
|
|
What is Java sensitive about
|
Case Sensitive
|
|
What are public and private called |
Access modifiers they control the level of access other parts of the program have to the code |
|
In terms of Java, what should the key word CLASS remind you of with this language?
|
everything in Java lives in a class
|
|
How should you think of a Class
|
as a container for the program logic that defines the behavior of the application
|
|
What follows the Class keyword
|
The name of the class
|
|
What must Class names start with and what can they be named
|
The must begin with an uppercase letter after that they can be letters of numbers and the length is almost unlimited
|
|
What are the standard naming conventions in a class
|
Class names are nouns that start with upper case letters if its multiple words use camelback
|
|
What names must match when it comes to classes |
The class name and the .java file (source code) must be the same |
|
What happens when you compile a file |
The compiler converts the source code into bytecode that the JVM can understand. During compilation syntax is checked and a .class file (byte-code) is created. |
|
What code does the compiler always start with
|
the code in the main Method
|
|
What is another term for Method
|
function a methods performs some sort of function
|
|
What method must you have in your source file for your class to run
|
main method
|
|
Do you declare the main method public, private, protected?
|
Public
|
|
What do braces generally denote
|
parts usually blocks of code
|
|
What ends each Java statement
|
a semi colon and statements can span multiple lines
|
|
How should you think of Java statements
|
Sentences that end with a semi colon
|
|
When calling methods what is the typical syntax |
object.method(parameters) |
|
What else are Parameters called
|
arguments
|
|
What is the minimum and maximum number of parameters
|
zero to infinity
|
|
If there are no parameters in a methods when must the method still have
|
empty parenthesis
|
|
Three ways of marking comments |
// single line comment /*multiline comment*/ /**Javadoc comment*/ |
|
What are the comment notation for automatic documentation
|
/** this will be automatically documents */
|
|
What is it called when every variable must declare type
|
Strongly Typed Language
|
|
What does the name Double type come from |
Refers to the fact that it has twice the precision of an int
An int is 32 bits a double is 64 bits |
|
How do you do quotes included in the sentence
|
\" Like System.out.println("\"We will test this page test new line\"");
|
|
What does every variable have and what order |
a type first then the name For example
double salary; int vacationDays; |
|
What can you name a variable
|
The first letter is a Letter and then letter and or numbers
|
|
Can you have multiple variable declarations of the same page
|
Yes but it is not recommended because of readability
|
|
Are variable names case sensitive |
Yes you can have Variable and variable and the compiler thinks they are different variables |
|
What must you do after declaring a variable
|
You must initialize it by means of an assignment statement
|
|
When declaring variable what is considered good practice
|
declare them as closely as possible to the point where they are going to first be used
|
|
With variable what is the key word Final denote
|
a constant which means you assign the variable once and then it is set once and for all
|
|
What is the convention for naming variable constants |
ALL CAPS |
|
What is the shortcut to X = X + 4
|
X +=4
|
|
What gives Java its portability |
A computation should yield the same results no matter which virtual machine executes it |
|
How do you increment or decrement a variable
|
n++ or n-- by one number
|
|
What operator do we use to test for equality |
== |
|
What operator do we use to test for inequality |
!= |
|
How do you short circuit an expression being evaluated if the firsrt one doesn't evaluate
|
expression1 && expression2 If the exp1 is shown to be false then exp2 is also false thus exp2 isn't evaluated Like x !=0 && 1/X. This will not allow a division be zero
|
|
expression1 || expression2
|
Condition first and if its true then exp1 is true if its not true then then exp2 is true Like x < y || X : Y
|
|
Which class contains mathematical function and constants
|
Math Class Like math.sqrt(x)
|
|
There is a subtle difference between println and the math class what is it
|
Println operates on an object the Math class does not and that is called static method
|
|
What does HTTP stand for and what is it used for |
Hyper Text Transfer Protocol how to transfer data across the internet |
|
Annotations
|
User to specify additional information about a Class or Interface LIKE they can be used to specify if the session is stateless or stateful they always start with @ sign
|
|
GUI
|
A graphical user interface (GUI) is a human-computer interface (i.e. a way for humans to interact with computers) that uses windows icons and menus and which can be manipulated by a mouse (and often to a limited extent by a keyboard as well).
|
|
What does void represent |
The method does not return a value |
|
What else is a method called when you are not being lazy
|
Method Declaration
|
|
What is the first part of a method called (before the curly braces) |
Method Header |
|
What is the part of a method called that is inside the curly braces |
Method body |
|
What is the main method, and what other method can call it? |
They are recipes and the first method called into action when the program begins running. The main is never called by another method |
|
What is a STATEMENT? |
It is a sentence that tell the computer to do something like
system.out.println(); |
|
The API is just a bunch of what?
|
Code and the code perform actions for us that we can piece together to create a program
|
|
What is the purpose of the Request object?
|
It represent the data submitted by the browser
|
|
What is the purpose of the Response object?
|
It represents the response that we are sending back to the client
|
|
What is the purpose of the Out object?
|
Represents output stream for the page, the content that will be sent back to the browser as the body of its response
|
|
What is the thing called that is stored in a variable?
|
a Value
|
|
AmountInAccount = 50.22;
What is this statement called? |
Assignment Statement |
|
What is MVC
|
Model - View - Controller
|
|
The instance fields hold values of an object the set of those values is what?
|
Their current state of that object and when you invoke a method on that object the state me be changed also
|
|
What is the key to making encapsulation work?
|
Have methods that never have direct access to the objects instance fields
|
|
What is the "cosmic superclass from which all others derive?
|
Object Class
|
|
When you are looking for what should be a class what is a simple rule of thumb?
|
Look for Nouns in the problem analysis, like Item, Order, Shipping Address, Payment, etc
|
|
When looking for what should be a method what is a good rule of thumb?
|
They are Verbs Like Add item to order, Cancel payment, Change shipping address
|
|
What , it called when a developer realizes that a method should never have been created in the first place?
|
Deprecated, and it is a good idea to stay away from deprecated methods, since there are better ones to replace them with
|
|
What is the deployment descriptor for the appilcation
|
the Web.xml file
|
|
What is the difference = or ==
|
= is an assignment to a variable and == is an equality check
|
|
Two type of data types?
|
Primitives and References
|
|
What are the primitive? |
byte, short, int, long, float, double, char, boolean |
|
What are the References?
|
Arrays Classes and Interfaces
|
|
What is the difference between these two
age = 16 newAge = ++age newAge = age++ |
the first one is still 17 because the pre-Increment increase the number before assigning. The second one assigns age to newAge first and then increments it
|
|
What is the & sign
|
And
|
|
What is the | sign
|
Or
|
|
What is the ^ sign
|
Exclusive or
|
|
What is the ~ sign
|
Compliment
|
|
What is the ! symbol
|
Not
|
|
What is the && symbol |
The and symbol If age<21 && hasId --java will not check the second condition if the first is not met |
|
What is the || symbol |
The or symbol if the first condition is true it will not check the second condition |
|
What are the two conversions and what does it mean
|
Implicit and Explicit
Implicit means the compiler will convert them automatically, explicit means you have to use the cast method |
|
How do you cast
|
with parenthesis like
like (double) 5. now the number is double or 5.0 |
|
What is the "\n" symbol? |
The new line escape character |
|
What is the "\t" symbol? |
The tab escape character |
|
How do you say 20 % 3 or i % 3
|
20 mod 3 or i mod 3
|
|
What are Strings
|
They are reference types not primitives. String is a class therefore it is capitalized
|
|
What are reference varibles |
Reference variables point to a location in memory. Java hides the pointers while some programs allow you to get the memory address |
|
When comparing two strings like "java" and "java" what should you not use |
Do not use the == because it java checks the memory location not the actual string. Sometimes the compiler will store the same string in different memory locations. Remember strings point to memory locations. Use the stringbuilder method equals() |
|
When comparing two strings what method should you use |
"string".equals("string") instead of the == symbol. Remember strings are references to memory only. and the same string may be in different memory locations depending on the compiler |
|
Would this be true or false
"Java".equals("java") |
false, they are not equal because java strings are case sensitive and each of there references will be stored in different memories
|
|
With strings like "Java".equals("java") what method can you use that makes this equal regardless of case |
equalsingnorecase, like "Java".equalsIgnoreCase("java") would make these equal |
|
What are items within an array called
|
Elements
|
|
In Arrays can there be mixed types or do all the types need to be the same?
|
All the types are the same
|
|
How are arrays referenced or referred to?
|
via an index and it starts at zero
|
|
What are the three ways to declare an array? |
int[] intArray; String stringArray[]; object[] objectArray; |
|
When adding class constructors what is a good practice |
Start with a default constructor. public dog(){ YOU CAN ADD ALL OF YOUR DEFAULT VALUES HERE } |
|
What are objects made from
|
The Class. the blueprint.
|
|
What defines an objects characteristics
|
The Class. The bueprint
|
|
What is an Entity?
|
It is an object -- the house, and the house was built from the Class--the blueprint
|
|
Can you have two methods with the same name
|
Yes but the parameter requirements must be different
|
|
Can we have two constructors in a Class
|
Yes like a default constructor which contains the fields defaulted
|
|
What is it called when you can have more than one method with the same name BUT different parameters
|
Method Overloading
|
|
Can you call the same method with different parameters (method overload) from the other method with the same name?
|
Yes e.g. you can can call eat() from eat(String food) method
|
|
What does static mean? |
General to the class and not specific to an object or instance. |
|
What does the final modifier mean |
It's a constant |
|
What is an overloading constructor?
|
It's a Class that has more than one constructor, of course of the same name because all constructors have the name of the class
|
|
When is this() used? |
When you are in a overloaded constructor and you want to call the default constructor |
|
Given: Cat c2 = new Cat();
What is the c2 called? |
Instance Variable Name |
|
What is any part of Java that has a value
|
An Expression
|
|
Any variable that is not a primitive type is what type? |
A reference variable |