Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Static Void - Data Structures - Quiz, Exercises of Data Structures and Algorithms

Main points of this past exam are: Static Void, Assign a Value, Amount of Memory, Program Display, Double Variable, Float Variable, Assignment Statements

Typology: Exercises

2012/2013

Uploaded on 04/07/2013

seshu_lin3
seshu_lin3 🇮🇳

4

(3)

59 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
22C:21 Computer Science II: Data Structures
Quiz 1A (15 Minutes)
Some questions have more than one correct answers; please select all
(Open book and notes No computers allowed)
September 2, 2010
1 What is the exact output of the following code?
double area = 3.5;
System.out.print("area");
System.out.print(area);
A. 3.53.5
B. 3.5 3.5
C. area3.5
D. area 3.5
3 To assign a value 1 to variable x, you write
A. 1 = x;
B. x = 1;
C. x := 1;
D. 1 := x;
E. x == 1;
5 Which of these data types requires the most
amount of memory?
A. long
B. int
C. short
D. byte
7 Which of the following expression results in a
value 1?
A. 2 % 1
B. 15 % 4
C. 25 % 5
D. 37 % 6
9 -25 % 5 is _____
A. 1
B. 2
C. 3
D. 4
E. 0
11 -24 % 5 is _____
A. -1
B. -2
C. -3
D. -4
E. 0
13 To assign a value 1 to variable x, you write
A. 1 = x;
B. x = 1;
C. x := 1;
D. 1 := x;
E. x == 1;
15 Suppose x is 1. What is x after x += 2?
A. 0
B. 1
C. 2
D. 3
E. 4
17 What is x after the following statements?
int x = 1;
int y = 2;
x *= y + 1;
A. x is 1.
B. x is 2.
C. x is 3.
D. x is 4.
pf2

Partial preview of the text

Download Static Void - Data Structures - Quiz and more Exercises Data Structures and Algorithms in PDF only on Docsity!

22C:21 Computer Science II: Data Structures Quiz 1A (15 Minutes) Some questions have more than one correct answers; please select all (Open book and notes No computers allowed) September 2, 2010

1 What is the exact output of the following code?

double area = 3.5; System.out.print("area"); System.out.print(area);

A. 3.53. B. 3.5 3. C. area3. D. area 3.

3 To assign a value 1 to variable x, you write

A. 1 = x; B. x = 1; C. x := 1; D. 1 := x; E. x == 1;

5 Which of these data types requires the most amount of memory?

A. long B. int C. short D. byte

7 Which of the following expression results in a value 1?

A. 2 % 1 B. 15 % 4 C. 25 % 5 D. 37 % 6

9 -25 % 5 is _____

A. 1 B. 2 C. 3

D. 4

E. 0

11 -24 % 5 is _____

A. - B. - C. - D. - E. 0

13 To assign a value 1 to variable x, you write

A. 1 = x; B. x = 1; C. x := 1; D. 1 := x; E. x == 1;

15 Suppose x is 1. What is x after x += 2?

A. 0 B. 1 C. 2 D. 3 E. 4

17 What is x after the following statements?

int x = 1; int y = 2; x *= y + 1;

A. x is 1. B. x is 2. C. x is 3. D. x is 4.

19 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 C. The program displays month is 9. D. The program has a syntax error, because 09 is an incorrect value.

21 To assign a double variable d to a float variable x, you write

A. x = (long)d B. x = (int)d; C. x = d; D. x = (float)d;

23 Which of the following assignment statements is illegal?

A. float f = -34; B. int t = 23; C. short s = 10; D. int t = (int)false; E. int t = 4.5;

25 What is the value of (double)(5/2)?

A. 2 B. 2. C. 3 D. 2. E. 3.

27 If you attempt to add an int, a byte, a long, and a double, the result will be a __________ value.

A. byte B. int C. long D. double

29 A Java character is stored in __________.

A. one byte B. two bytes C. three bytes D. four bytes

31 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");

33 The unicode of 'a' is 97. What is the unicode for 'c'?

A. 96 B. 97 C. 98 D. 99

35 What is the printout of System.out.println('z' - 'a')?

A. 25 B. 26 C. a D. z

37 Which of the following assignment statements is correct?

A. char c = 'd'; B. char c = 100; C. char c = "d"; D. char c = "100";

39 Note that the Unicode for character A is 65. The expression "A" + 1 evaluates to ________.

A. 66 B. B C. A D. Illegal expression