0% found this document useful (0 votes)
4 views2 pages

Quiz I (Spring 2018)

This document is a quiz for the Engineering Programming course at the Lebanese American University, focusing on Java programming concepts. It includes multiple-choice questions about Java's characteristics, potential errors, and code behavior. The quiz assesses students' understanding of Java syntax, runtime errors, compile-time errors, and variable manipulation.

Uploaded by

shihab.azzam27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Quiz I (Spring 2018)

This document is a quiz for the Engineering Programming course at the Lebanese American University, focusing on Java programming concepts. It includes multiple-choice questions about Java's characteristics, potential errors, and code behavior. The quiz assesses students' understanding of Java syntax, runtime errors, compile-time errors, and variable manipulation.

Uploaded by

shihab.azzam27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

LEBANESE AMERICAN UNIVERSITY

Electrical and Computer Engineering Dept

COE 212
Engineering Programming
Section I
Spring 2018
W. FAWAZ

Quiz I
Problem I

1) Which of the following statements about the Java language is false?


a. Java is a strongly typed programming language
b. Java is an object-oriented programming language
c. Both of the above statements are false
d. None of the above statements is false

2) Which of the following statements may result in a run-time error? Assume


that scan is a Scanner object that was instantiated properly.
a. float val = 23.5;
b. int val = scan.nextInt();
c. int val = 23.5;
d. None of the above

3) Which of the following statements may produce a compile-time error?


a. System.out.println(“\\”);
b. System.out.println(“\\\”);
c. Both of the above
d. None of the above

4) Which of the following statements causes a conversion via promotion to


happen?
a. String str = “hi” + 5;
b. double val = 10/5;
c. Both of the above
d. None of the above

5) Which of the following statements increments the value of the variable called
val by 10? Assume that the variable val was declared and initialized properly.
a. int y, z=9;
y = z++;
val += y;
b. int y = 19, z;
y%=10;
z = ++y;
val += z;
c. Both of the above
d. None of the above
Problem II

1. The following statement can be used to import the Scanner class:


Import java.util.Scanner;
Answer: True False

2. Consider the following statement where a Scanner object called scan is used
to obtain a value from the end user. Assume that scan was created properly.
String val = scan.nextLine();
This statement produces a run-time error if the end user types a decimal
value of 23.5 and then hits the return key (Enter).
Answer: True False

3. Only widening conversions are supported by the assignment operator.


Answer: True False

4. The following statement prints: abc


System.out.print(‘a’ + ‘b’ + ‘c’ + “”);
Answer: True False

5. The following code fragment produces a compile time error:


int Val;
final int val = 23;
System.out.println(val);
Val=34;
System.out.println(Val);
Answer: True False

You might also like