ISYS 303 - Previous Quizzes Flashcards

1
Q

Which program is responsible for allowing someone to run a Java program?

A

JRE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
Which is NOT a key consideration for using Java?
Simple
Secure
Compiles into an executable file
High Performance
A

Compiles into an executable file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
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
A

Encapsulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
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
A

Polymorphism

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
Which is NOT a valid Java data type. IOW, which could you NOT use to declare a variable.
integer
boolean
double
char
A

integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
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
A

byte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

A float data type can hold a larger number and larger decimal than a double
True
False

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
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;
A

String sName = “Greg”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
What could you embed in a System.out.println statement and cause a blank line to be inserted?
"/t"
"/n"
"\n"
"\\"
A

“\n”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

Nothing, there are bugs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
What key word is used to create an object?
Student
Scanner
new
main
A

new

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

scanInput.nextLine();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A ____________________________ is like a template or a mold that is used to instantiate objects.

Method
Class
Program
Parameter

A

Class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Assuming iCount was declared properly, how many times will “Hi” be printed?

for (iCount = 0; iCount

A

None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

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

A

None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

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

A

5 3 1

19
Q

Assuming iCount was declared properly, what would the following print?

iCount = 0;
while (iCount

A

None of the above

20
Q

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;
}

A
String displayName()
{
   return studName;
}
21
Q

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

A

False

22
Q
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
A

Constructor

23
Q

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();
A

Student oStudent = new Student();

24
Q

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;
}
A
void studLoad(String sName, int iNum)
{
   this.studName = sName;
   this.studNumber = iNum;
}
25
Q

When you compile your Java code, the JVM converts it into Bitmaps which is a set of highly optimized instructions executed by the Java run-time system
True
False

A

False - bytecode

26
Q
The process of designing classes so that the user doesn't really need to know all of the details of the class but can still use and implement the class (black box approach) is called:
Polymorphism
Encapsulation
Instantiation
Constructor
A

Encapsulation

27
Q

The process of creating a new object is called encapsulation
True
False

A

False

28
Q

The following statement should be included in a class because it tells Java where to start and can be called from outside the class

private static void main( String args[])
True
False

A

False

29
Q

Assumming that all the code before this code and after is correct, what is the last thing printed using the following source code if the user types in the value of 20 from the keyboard:

int iScore;
Scanner scanInput = new Scanner(System.in);
System.out.println("Enter the score:");
iScore = scanInput.nextInt();
System.out.println( "iScore" );

20
30
unknown
None of the above

A

None of the above

30
Q

Assuming that all the code before and after is correct, what would the following display?

int iCount = 5;
if ( iCount = 6 )
{
   System.out.println("Win");
}
else
{
   System.out.println("Lose");
}

6
Win
Lose
None of the above. This is an error

A

None of the above. This is an error

31
Q
How many bugs/Compile errors do you see in the java source code file called 'Test.java'? NOTE: Some lines might have more than one bug. Double quotes count as one error.
/******************************************************
* Greg Anderson *
* Sample test code *
******************************************************/
import java.util.Scanner;
public class Test
{
   public static void main(String[] args)
   {
      Scanner oScan = Scanner();
      String sName;
      System.out.println("Enter your name:")
      sName = Scanner.nextInt();
      System.out.println(Welcome sName);
  }
}

5
6
7
There are no errors in this code

A

7

32
Q
How many bugs/compile errors do you see in the following java source code file called 'Test.java'?
/******************************************************
* Greg Anderson *
* Sample test code *
******************************************************/
import java.util.Scanner;
public class AddItUp
{
   public static void main(String[] args)
   {
       int iNum1 = 10;
       int iNum2 = 20;
       int iSum;
       iSum = iNum1 + iNum2;
       System.out.println(iSum);
   }
}

1
3
4
There are no errors

A

1

33
Q

Assuming all code before and after are correct, what would the following code display:

int iCount = 5;
if (iCount == 9)
{
   System.out.println(iCount++);
}
else
{
   System.out.println(--iCount);
}

5
4
6
Cannot be determined

A

4

34
Q

What does the following print?

int iCount = 5;
switch(iCount)
{
case 5:
System.out.println("Utah");
case 10:
System.out.println("Texas");
}

Utah
Texas
UtahTexas (on the same line)
None of the above

A

None of the above

35
Q

Assuming iCount was declared properly, how many times will “Your hair looks ridiculous. Can I have your number please?” be printed?

for (int iCount = 0; iCount

A

1

36
Q
Which of the following forces was NOT a factor that played a role in the creation of the Java programming language?
Secure
Robust
Interpreted
High Performance
All were factors
A

All were factors

37
Q

The JVM is the Java run-time system responsible for executing a highly optimized set of instructions
True
False

A

True

38
Q

What logical result would the following source code return?

int iNum1 = 10;
int iNum2 = 20;
int iNum3 = 30;
if ( (iNum1 > iNum2) && ( iNum2 > iNum3) && (iNum3 > iNum1) )

True
False

A

False

39
Q

What logical result would the following source code return?

int iNum1 = 20;
int iNum2 = 30;
int iNum3 = 40;
if ( (iNum1 > iNum2) || ( iNum2 > iNum3) || (iNum3 > iNum1) )

True
False

A

True

40
Q

What is the minimum number of times a while loop will execute?
0
1
unknown

A

0

41
Q

Arrays and objects are passed by value and other data types like int are passed by reference
True
False

A

False

42
Q

The Public modifier indicates that a value is visible only in the parent class
True
False

A

False

43
Q

The Private modifier indicates that a value is visible only in the current class and all subclasses
True
False

A

False

44
Q

The Protected modifier indicates that a value is visible in the current class only
True
False

A

False