CS 150 Calvin Amadi

58 flashcardsby Calvin
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
Why do computers use zeros and ones?
because digital devices have two stable states and it is natural to use one state for 0 and the other for 1
2
_______ are instructions to the computer.
Programs and Software's
3
________ is the physical aspect of the computer that can be seen.
Hardware
4
Computer can execute the code in ________.
machine language
5
________ is an operating system.
6
Java ________ can run from a Web browser.
applets
7
________ is interpreted.
Java
8
The main method header is written as:
public static void main(String[] args)
9
Which of the following statements is correct to display Welcome to Java on the console?
System.out.print("Welcome to Java");

System.out.println("Welcome to Java");
10
The JDK command to compile a class in the file Test.java is
javac Test.java
11
Java compiler translates Java source code into ________.
Java bytecode
12
The extension name of a Java bytecode file is
class
13
________ is a software that interprets Java bytecode.
Java virtual machine
14
The extension name of a Java source code file is
.java
15
Every statement in Java ends with ________.
a semicolon ( ; ), known as the statement terminator.
16
A block is enclosed inside ________.
braces
17
________ are secondary storage.
floppy disk, hard disk, CD
18
The keywords in Java are all in lowercase.
True
19
You use ________ to run a Java program.
Java
20
Which of the following is a valid identifier?
radius
21
Which of the following are correct ways to declare variables? A)int length, width; B)int length; int width; C)int length, int width; D)int length; width;
A)int length, width;

B)int length; int width;
22
________ is the Java assignment operator.
=
23
Which of the following assignment statements is incorrect.

A)i=j=k=1;

B)i=1=j=1=k=1;

C)i==j==k==1;

D)i=1; j=1; k=1;
B)i=1=j=1=k=1;

C)i==j==k==1;
24
To declare a constant MAX_LENGTH inside a method with value 99.98, you write
final double MAX_LENGTH=99.98;
25
Which of these data type requires the most amount of memory?

A)byte B)short C)long D)int
C)long
26
To declare an int variable number with initial value 2, you write:

A)int number=2l;

B)int number=2L;

C)int number=2;

D)int number=2.0;
int number=2;
27
Which of the following expressions will yield 0.5?

A)(double) (1 / 2)

B)1 / 2

C)1.0 / 2

D)1 / 2.0

E)(double) 1 / 2
C)1.0 / 2

D)1 / 2.0

E)(double) 1 / 2
28
Which of the following expression results in a value 1?

A)2 % 1

B)15 % 4

C)25 % 5

D)37 % 6
D)37 % 6
29
Analyze the following code.public class Test {public static void main(String[ ] args) {int month=09;System.out.println("month is "+month);}}

A)The program displays month is 09

B)The program displays month is 9.0

C)The program displays month is 9

D)The program has a syntax error, because 09 is an incorrect literal value.
The program has a syntax error, because 09 is an incorrect literal value.
30
Which of the following assignment statements is illegal?

A)float f=-34;

B)int t=23;

C)short s=10;

D)int t=4.5;

E)int t=(int)false;
D) int t=4.5;

E) int t=(int)false;
31
What is the value of (double)5/2?

A)3;

B)3.0;

C)2.5;

D)2;
E)2.0;
2.5
32
A Java character is stored in ________.
two bytes
33
33)33)Which of the following statement prints smith\exam1\test.txt?

A)System.out.println("smith\exam1\test.txt");

B)System.out.println("smith"\exam1"\test.txt");

C)System.out.println("smith\"exam1\"test.txt");

D)System.out.println("smith\\exam1\\test.txt");
D. System.out.println("smith\\exam1\\test.txt");
34
The ________ method parses a string s to an int value.

A)integer.parseInteger(s);

B)integer.parseInt(s);

C)Integer.parseInt(s);

D)Integer.parseInteger(s);
C. Integer.parseInt(s);
35
The ________ method parses a string s to a double value.
double.parse(s);
36
The expression (int)(76.0252175 * 100) / 100 evaluates to ________.

A)76.02

B)76.0252175

C)76.03

D)76
D) 76
37
If a program compiles fine, but it produces incorrect result, then the program suffers ________.
a logic error
38
You can always assign a value of long type to a variable of int type without loss of precision.
False
39
You can always assign a value of int type to a variable of long type without loss of information.
True
40
A variable may be assigned a value only once in the program.
False
41
You can change the value of a constant.
False
42
To add a to b and store result in b, you write:
b+=a;
43
To declare a constant PI, you write
final double PI=3.14159;
44
A Java statement ends with a ________.
semicolon (;)
45
Which of the following operators has the highest precedence?

A)/

B)+

C)*

D)casting
casting
46
An int variable can hold ________.
A)'x'

B)93

C)True

D)98.3

E)A and B
E)A and B
47
If you attempt to add an int, a byte, a long, and a double, the result will be a ________ value.
double;
48
What is the printout of the following code:double x=10.1;int y=(int)x;System.out.println("x is "+x+" and y is "+y);

A)x is 10.0 and y is 10.0

B)x is 10.1 and y is 10

C)x is 10.1 and y is 10.0

D)x is 10 and y is 10

E)x is 11 and y is 11
B) x is 10.1 and y is 10
49
In Java, the word true is ________.
D) a Boolean literal
50
Suppose x=10 and y=10 what is x after evaluating the expression (y > 10) & (x++>10).

A)9

B)11

C)10
B) 11
51
Suppose x=10 and y=10 what is x after evaluating the expression (y > 10) && (x++>10).
C)10
52
Which of the following code displays the area of a circle if the radius is positive.

A)if (radius>=0)

System.out.println(radius * radius * Math.PI);

B)if (radius<=0) System.out.println(radius * radius * Math.PI);

C)if (radius !=0) System.out.println(radius * radius * Math.PI);

D)if (radius>0) System.out.println(radius * radius * Math.PI)
D)if (radius>0) System.out.println(radius * radius * Math.PI);
53
53)What is y after the following switch statement is executed? x=3;switch (x+3) {case 6: y=0;case 7: y=1;default: y+=1;}

A)3

B)2

C)4

D)1
B) 2
54
What is the printout of the following switch statement?char ch='b';switch (ch) {case 'a':System.out.print(ch);case 'b':System.out.print(ch);case 'c':System.out.print(ch);case 'd':System.out.print(ch);}

A)b

B)bcd

C)abcd

D)bbb

E)bb
E)bb
55
Analyze the following program fragment: int x; double d=1.5; switch (d) {case 1.0: x=1; case 1.5: x=2;case 2.0: x=3;}

A)The switch control variable cannot be double.

B)The program has a syntax error because the required break statement is missing in the switch statement.

C)The program has a syntax error because the required default case is missing in the switch statement.

D)No errors
A) The switch control variable cannot be double.
56
You can always convert a switch statement to an equivalent if statement.
True
57
The order of the precedence (from high to low) of the operators+, *, &&, ||, & is:

A)&, ||, &&, *,+

B)*,+, &, ||, &&

C)*,+, &&, ||, &

D)&&, ||, &, *,+

E)*,+, &, &&, ||
D)&&, ||, &, *,+
58
What is the value of the following expression? true || true && false
True
Study all 58 cards for free