Introduction to Java Flashcards
What does OOP stand for?
Object Oriented Programming
what does OOP help with?
OOP simplifies software development and maintenance by providing some rules
In OOP languages everything is associated with?
classes, objects, attributes and methods
a class is _______________ or generic description
blueprint
a class contains?
general attributes or properties
Objects are created from a _________
class
TRUE or FALSE…
an object represents specific attributes values that apply
True
TRUE or FALSE…
Attributes is the information stored in a method.
False. Attributes is the information stored within an object. It represents the data of an object.
Method represents what…methods perform what…..
methods represents behaviors and perform actions.
What are the main data types?
int
float
char
boolean
string
what is a variable?
a variable is used to store values in Java for later use.
example int age = 65; or String name = “Jonny”
what is an array used to store?
multiple values in a single variable
Which of the following is the correct way to code an array?
A. String [] trees = {"oak, spruce, pine"}; B. String trees [] = {"oak", "spruce", "pine"}; C. String trees = {"oak", "spruce", "pine"}; D. String [] trees = {"oak", "spruce", "pine"};
D.
String [] trees = {“oak”, “spruce”, “pine”};
What is the code needed to make this if work?
String color = "red"; if (color == "blue") { System.out.println("I'm sorry please pick red"); } elseif { System.out.println("RED"); }
elseif should look like elseif (color == “red”)
String color = “red”;
if (color == "blue") { System.out.println("I'm sorry please pick red"); } elseif (color == "red") { System.out.println("RED"); }
What is a class?
a structure where we define attributes and methods, which are utilized by the objects.
how do you create a class?
use the class keyword followed by the name of the class
example class bird {
what does the Main Method do?
the Main Method initiates the program.
True or False:
Does letter case matter in java?
true
does the main method come before or after the class?
after
the syntax should look like…..
public class MyClass {
public static void main() {
//System.out.println(“example”);
}
}
What must the class name match?
the class name must match the file name.
what is a class diagram?
its a blueprint of a class.
what does a class diagram show?
a class diagram shows the names and attributes of the classes, relationships between classes, and sometimes the methods of the classes.
write this code out based on the class diagram (each box will instead be a number)
- Store
- name: String
- address: String
- Store(name:String, address: String)
- +open(): String
- +close(): void
class Store {
private String name;
private String address;
public Store (String name, string address) { //do things } public String open () { //do things } public void close () { //do things } }
what does class diagrams NOT do
class diagrams does not describe functionality.
what is a sequence diagram?
a sequence diagram is a plan for how code will interact with each other and the order they will interact.