ICS 111 Midterm 1 Review
This class is ICS111 1.True 2.False
Variable names should be descriptive and readable 1.True 2.False
line of Java code “// System.out.println("Hello");” will 1.do nothing 2.cause "Hello" to be output 3.cause a syntax error 4.cause "(Hello)" to be output 5.there is no way to know without executing this line of code
Is this a valid Java identifier? RESULT 1.Yes 2.No 3.Yes but it doesn’t follow the Java coding standards 4.What is an identifier?
Is this a valid Java identifier? black&white 1.Yes 2.No 3.Yes but it doesn’t follow the Java coding standards
The // comment runs to the end of the line only. 1.Yes 2.No
What output is produced by the following statement? System.out.println(“50 plus 25 ” ); 1.50 plus plus There will be an error
What output is produced by the following statement? System.out.println(“50 plus 25 ” + (50+25)); 1.50 plus plus There will be an error
What value is contained in the int variable size after this is executed: size = 18; size = size + 12; size = size/4; 1.This will generate an error
What value is contained in the float variable depth after the following statements are executed? depth = 2.4; depth = 20 – depth; There will be an error
int iResult; int num1 = 25; int num4 = 5; iResult = num1/num4; No idea
int iResult; int num1 = 25; int num4 = 5; iResult = num4/num1; No idea , again…
float fResult = 0; int num1 = 25; int num4 = 5; fResult = num1/num4; error
float fResult = 0; int num1 = 25; int num4 = 5; fResult = num4/num1; error
float fResult = 0; int num1 = 25; int num4 = 5; fResult = (double)num4/num1 ; error
float fResult = 0; int num1 = 25; int num4 = 5; fResult = (float)num4/num1; error
int num3 = 21; int num4 = 5; int iResult =0; int iResult = num3%num4; error
I like this class. 1.Yes 2.No
I am learning UNIX 1.Yes 2.No
I will recommend my friends to take this class 1.Yes 2.No way Jose 3.I’m waiting for the first midterm exam result.
String s = “Hello World”; s.substring(3); System.out.print(s); //what will be printed? 1.llo World 2.lo World 3.l 4.Hello World
String s = “Hello World”; System.out.print(s.substring(3)); //what will be printed? 1.llo World 2.lo World 3.l 4.I have no clue.
String s = “Hello World”; System.out.print(s.substring(0)); //what will be printed? 1.Hello World 2.elloWord 3.An error will occur 4.I don’t want to think right now.
String s = “Hello World”; System.out.print(s.length( )); //what will be printed? I’m sleeping…zzzz
String s = “Hello World”; System.out.print(s.indexOf(‘a’)); //what will be printed? 1.There will be an error
String s = “Hello World”; System.out.print(s.substring(3,4)); //what will be printed? 1.llo World 2.lo World 3.l 4.Please, stop it!!!
String s = “Hello World”; System.out.print(s.charAt(0)); //what will be printed? 1.H 2.d 3.l 4.There will be an error
String s = “Hello World”; System.out.print(s.charAt(-1)); //what will be printed? 1.H 2.d 3.A blank 4.There will be an error An IndexOutOfBoundsException
We import packages (Java libraries) so that we do not have to re-invent the wheel. 1.True 2.False
When using the DecimalFormat class, using # and using 0 is the same 1.True 2.False
When using the DecimalFormat we can even add units to the numbers that we are formatting 1.True 2.False
Random gen = new Random( ); int num; num = gen.nextInt( ); 1.Will generate a number between 0 and the highest int number. 2.Will generate a number within the whole int range 3.Will generate a number between 0 and 1
Random gen = new Random( ); int num; num = gen.nextInt(20); //will generate a number between: 1.0 and and and and 20 5.Can’t count now. Java is zero based
Random gen = new Random( ); int num; num = gen.nextInt(20)+5; //will generate a number between: 1.5 and and and and and 25
Are you ready for the midterm now? 1.Yes 2.No 3.Just a little bit 4.Now I know that I don’t know. 5.What midterm?