COP 2210 Sample Exam Questions .edu



COP 2210 Sample Exam Questions Kraynek

5 pts

1. What is the difference between a class and a class object?

5 pts

2. What is the difference between an class object and an class variable?

5 pts

3. Suppose that s1 and s2 are String variables. Explain the difference between the comparison s1.equals(s2) and the comparison s1 == s2.

5 pts

4. What is the difference between a primitive type variable and a class variable?

10 pts

5. Consider the following statements:

String s1 = new String(“abcdef”);

String s2 = new String(“123abc”);

What are the values of the following expressions?

a. s1.substring(3)

b. s1.substring(1,4)

c. s1.charAt(0) == s2.charAt(3)

d. s1.substring(0,3).equals(s2.substring(4))

e. s1 + s2

10 pts

6. Suppose we have the declarations:

int x = 37;

String s = “abcdefb”;

What are the values of the following expressions?

a. 29 % 5

b. 29 / 5

c. 5 * (x / 5) +( x % 5)

d. s.indexOf(“b”)

e. s == new String(“abcdefb”)

5 pts

7. What is the output of the following segment?

int n = 35;

while( true ) {

if( n ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download