Title | Sample Test 1 with Answers |
---|---|
Course | Introduction to Computer Science |
Institution | Syracuse University |
Pages | 4 |
File Size | 102.3 KB |
File Type | |
Total Downloads | 12 |
Total Views | 141 |
Quiz and Notes...
ICSI/ICEN 201
Sample Test #1
Student Id:
Section A: Mark the following statements as TRUE/FALSE.
[10
1 = 10 marks]
int hours += 40;
// A&&B
A
B
double myAge; myAge = 35; else
&&
if
||
Section B: Choose the correct answer to fill in the blanks.
[10
float
myString int myString = myString + 10; myString += 10; myString =+ 10; 10 += myString; char letter = “Z”;
x = (int) number;
1 = 10 marks]
ICSI/ICEN 201
Sample Test #1
Student Id:
Section C: Correct the syntax errors, if any, in the following Java program segments. [10 int hours = 40; double grossPay, payRate = 25.0; grossPay = hours * payRate; System.out.println(Your gross pay is $ + grossPay); 4th Line:
System.out.println(“Your gross pay is $” + grossPay);
char firstLetter; System.out.println(firstLetter); firstLetter char firstLetter = ‘A’; or char firstLetter; firstLetter = ‘A’;
String name, double grossPay; Keyboard myKey = new Keyboard(System.in); System.out.print(“What is your name?”); name = myKey.nextString(); String name; double grossPay; Scanner myKey = new Scanner(System.in); System.out.print(“What is your name?”); name = myKey.nextLine();
1= 10 marks]
ICSI/ICEN 201
Sample Test #1
Student Id:
float value = 5.0E2; System.out.println (“ ” + value);
1st Line: float value = 5.0E2F;
if (number2 = 0) System.out.println(“Number2 can not be zero.”); if (number2 == 0) System.out.println(“Number2 can not be zero.”); ‘=’ should be replaced with some relational operator e.g. ==, !=,...