Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
UMKD SDP2 2016-2017.docx
Скачиваний:
25
Добавлен:
14.10.2016
Размер:
126.72 Кб
Скачать

Variant 3

1) The final exam includes two parts: open test and coding, you need to send 2 files (.doc files) with the answers to the test, and a .zip file with the code.

  • Pay attention to the name of the file.

  • After the coding is done do not send only a .java file, provide the entire folder.

2) All the answers in the final test must be highlighted in red font, the answers should be short, clear, and fully disclose the meaning of the question.

3) During the coding process, the code should be properly commented, should not contain unnecessary actions, and must fulfill all the requirements according to the task.

4) The final exam is 3 hours, all the answers must be sent 5-10 minutes before the test close, in case if the student does not have time to send an answer, the evaluation of the final exam will be 0%.

5) In the file for the test at the top you need to specify which option you choose for the coding (specify either 75 or 100). 75 and 100 suggests the maximum score for the second part - the coding.

  • In the case that a student will perform the test perfectly and perfectly perform coding by 75%, the highest score will be 87.5.

  • In the case that a student will perform the test perfectly and perfectly perform coding by 100%, the highest score will be 100. 

Test (1st part of Exam)

1. Convert the decimal value of 55 to octal. Show your work.

2. For each following expressions, specify the Java type and value that would be generated bye the expression:

Assume “a” and “b” are integer variable of the Java type “int” and “c” and “d” are approximations of real values of java type “double” with the following values:

int a = 7;

int b = 9;

double c = 1.5;

double d = -2.5;

Expression

Type

Value

a + b

b - 2.0

a / b

b / a

a % b

b % a

a + b / 4.0

(int) c + d

c + (int) d

c + b / 2 – d


3. In the space provided, show what the output generated by performing the following Java statements would be.

System.out.print("The answer is: ");

int a = 5;

double result = a / 2 + 1;

System.out.println(result);

System.out.println("The end.");

4. What would the following code display?

String stringA = "How worldly is that?";

String probe = "howdy";

int hitCount = 0;

char c;

for (int i=0;i<probe.length();i++) {

c = probe.charAt(i);

for (int j=0;j<stringA.length();j++) {

if (stringA.charAt(j) == c)

hitCount++;

}

}

System.out.println(hitCount+" hits");

Place your output here:

5. What would the following code display?

double [] numbers = {1,2,3,4,5};

double sum = 0;

for (int i=0;i<numbers.length;i++) {

sum += numbers[i];

}

System.out.println("Average = "+(sum / numbers.length));

Place your output here:

6. Determine what the printed output of this program will be:

String stringA = " How easy is Java to learn?";

String probe = " javascript";

int hitCount = 0;

char c;

for (int i=0;i<probe.length();i++) {

c = probe.charAt(i);

for (int j=0;j<stringA.length();j++) {

if (stringA.charAt(j) == c)

hitCount++;

}

}

System.out.println(hitCount+" hits");

Describe program trace below.

7. Write the java code required to solve the following problem. Using a class's constructor to initialize values, create a Java Class which offers the following two public methods:

Date getCreationDate();

String getCreatorName();

Place your output here:

8. In the space provided, show variables value after performing the following Java code:

int x = 3, y = 5, z = 2;

if (x <= y) {

x += z;

if (z != x) { y = (x - z) / y;}

z++;

} else if (y == 0) {

y++;

z *= y;

}

-------------------------------------------------------------------------------------------------

Coding (2nd part of Exam)

Соседние файлы в предмете Программирование на Java