ISYS 303 - Previous Quizzes Flashcards
Which program is responsible for allowing someone to run a Java program?
JRE
Which is NOT a key consideration for using Java? Simple Secure Compiles into an executable file High Performance
Compiles into an executable file
The process that protects code from changes by other people and also hides details or how things work (like driving a car) by binding code and data together is called..... OOP Encapsulation Polymorphism Inheritance
Encapsulation
The ability to use a single interface (or method) but use it for different types of actions (like printing an excel, word, or pdf file) is called ... OOP Encapsulation Polymorphism Inheritance
Polymorphism
Which is NOT a valid Java data type. IOW, which could you NOT use to declare a variable. integer boolean double char
integer
Which data type should be used if you were worrying about memory and were trying to represent score on a test? byte short int long
byte
A float data type can hold a larger number and larger decimal than a double
True
False
False
Which would be the correct Java statement for declaring a string variable and assigning it the value of Greg string greg; String sName = "Greg"; String sName = 'Greg'; String "Greg" = sName;
String sName = “Greg”;
What could you embed in a System.out.println statement and cause a blank line to be inserted? "/t" "/n" "\n" "\\"
“\n”
What would the following lines of Java code display (assuming all code before and after were correct)
int iCount;
iCount = 2;
iCount++;
System.out.println(++iCount);
3
4
2
unknown
4
What would the following Java source code display assuming all code before and after were correct
int iCount = 2;
System.out.println(–iCount);
2
1
0
unknown
1
What does the following print?
int iCount = 10; if (iCount = 5) { System.out.println("Hi"); } else { System.out.println("Bye"); }
Hi
Bye
Hi and Bye
Nothing, there are bugs
Nothing, there are bugs
What key word is used to create an object? Student Scanner new main
new
Scanner scanInput = new Scanner(System.in);
What statement clears the buffer? (HINT: remember, there is a carriage return left in the buffer when you go from scanning an integer to scanning a string so the computer just grabs the enter key and thinks that value is the input. We get around this by using multiple scanner objects - one for strings, one for ints, etc.)
scanInput.close();
scanInput.nextLine();
scanInput.flush();
It cannot be done
scanInput.nextLine();
A ____________________________ is like a template or a mold that is used to instantiate objects.
Method
Class
Program
Parameter
Class
Assuming iCount was declared properly, how many times will “Hi” be printed?
for (iCount = 0; iCount
None of the above
Assuming iCount was declared properly, what will the following print?
for (iCount = 5; iCount > 0; iCount = iCount + 2)
System.out.println(iCount);
5 3 1
5 4 3 2 1
4 3 2 1
None of the above
None of the above
Assuming iCount was declared properly, what would the following print?
for (iCount = 5; iCount > 0; iCount = iCount - 2)
System.out.println(iCount);
5 3 1
5 4 3 2 1
4 3 2 1
None of the above
5 3 1
Assuming iCount was declared properly, what would the following print?
iCount = 0;
while (iCount
None of the above
Assuming that a Student object has been instantiated and the studName instance variable has been assigned a value, which of the following methods would be used to return the studname?
String displayName()
void displayName() { return studname; }
String displayName() { return studName; }
displayName(String)
{
return;
}
String displayName() { return studName; }
When objects are created from the same class, the occupy the same memory locations so as to reduce the amount of memory being used
True
False
False
When you see a method name that is the same name as the class you can assume that the method is ... Constructor not going to be called an error encapsulation
Constructor
Using the following code, what statement would you use to create an object of the class in the code listed below:
class Student { String studName; double gpa; int studNumber; }
Scanner scanInput = new Scanner(System.in); Scanner Student = new Scanner(System.in); Student student = new Student; Student oStudent = new Student();
Student oStudent = new Student();
Which of the following methods would receive a parameter for the student name and one for the student id and NOT return a value?
void studLoad()
void studLoad(studName, studNumber) { studName = this.name; studNumber = this.id; }
String studLoad(String sName, int iNum) { this.studName = sName; this.studNumber = iNum; }
void studLoad(String sName, int iNum) { this.studName = sName; this.studNumber = iNum; }
void studLoad(String sName, int iNum) { this.studName = sName; this.studNumber = iNum; }