Unit 2: Java Fundamentals Flashcards
True or False: Java is an object-oriented language
True
Objects can not be created without creating a blue-print associated to that object. This blue-print is known as…
Class
In Java, all codes are written inside…
Classes
True or False: class is not a keyword (reserved word)
False
What would the line of code “System.out.println(“Hello Everyone!”);” display and where would it display?
The code would display Hello Everyone! on the standard output (monitor)
True or False: System is a class
True
True or False: By convention, the first letter of each word in the class name is not capitalized
False
Define: Class
A class is a template, blueprint or contract that defines the attribute (data field) and methods (functionalities/behavior) associated with certain entities (the instances of that class)
Define: Object
An object is an instance of class. An instantiated object is given a name, and it is created/placed in the memory using the structure described within a class declaration
Computer can execute code in _________
Machine language
The extension of a java virtual object file is:
.class
The extension of a java source code file is:
.java
True or False: The source code in java is compiled into bytecode
True
True or False: Bytecode is machine dependent
False
True or False: In java, the main() method has to be declared as a static method of a class
True
In the following java statement, what does “System” represent:
System.out.println(“Welcome to Java!”);
A class
The name of a variable or object is used to:
Distinguish one variable from another
The type of a variable or object is used to:
Tell the memory how much this variable needs and what can be assigned to it
What type of statement is this:
float w_lb, w_kg
A declaration statement
What type of statement is this:
w_kg = w_lb * 0.454
An assignment statement
True or False: a+b/c+d is the same as a+(b/c)+d in java language
True
What value will be left over in this math statement:
3-8%5
Zero
What is the value of newNum after these statements:
int i = 10;
int newNum = 10 * i++;
100
True or False: The following two java statements perform the same operation:
regWages = regPay + overTime;
regPay + overTime = regWages;
False
True or False: The following two java statements will result in the same value for y:
y = a + b * c; y = b * c + a;
True
True or False: The following statement doubles the value stored in answer:
answer *= 2;
True
True or False: The following statement will evaluate to true if x is between 1 and 100 or the number is negative:
((x<100) && (x>1)) || x<0
True
What will the value of c be after the following statements:
int a = 3, b = 2;
double c;
c = (a+b)/2;
2.0
What will the value of c be after the following statements:
float a = 3, b = 2;
int c;
c = (a+b)/2;
The code will not compile