Presentation is loading. Please wait.

Presentation is loading. Please wait.

ICS 111 Midterm 1 Review. This class is ICS111 1.True 2.False.

Similar presentations


Presentation on theme: "ICS 111 Midterm 1 Review. This class is ICS111 1.True 2.False."— Presentation transcript:

1 ICS 111 Midterm 1 Review

2 This class is ICS111 1.True 2.False

3 Variable names should be descriptive and readable 1.True 2.False

4 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

5 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?

6 Is this a valid Java identifier? black&white 1.Yes 2.No 3.Yes but it doesn’t follow the Java coding standards

7 The // comment runs to the end of the line only. 1.Yes 2.No

8 What output is produced by the following statement? System.out.println(“50 plus 25 ” + 50+25); 1.50 plus 25 5025 2.50 plus 25 75 3.There will be an error

9 What output is produced by the following statement? System.out.println(“50 plus 25 ” + (50+25)); 1.50 plus 25 5025 2.50 plus 25 75 3.There will be an error

10 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 2.30 3.7 4.7.3 5.8

11 What value is contained in the float variable depth after the following statements are executed? depth = 2.4; depth = 20 – depth; 1.17 2.18 3.17.6 4.There will be an error

12 int iResult; int num1 = 25; int num4 = 5; iResult = num1/num4; 1.4 2.4.0 3.5 4.0 5.No idea 

13 int iResult; int num1 = 25; int num4 = 5; iResult = num4/num1; 1.4 2.0.2 3.5 4.0 5.No idea , again…

14 float fResult = 0; int num1 = 25; int num4 = 5; fResult = num1/num4; 1.4 2.4.0 3.5 4.0 5.error

15 float fResult = 0; int num1 = 25; int num4 = 5; fResult = num4/num1; 1.4 2.4.0 3.5 4.0 5.error

16 float fResult = 0; int num1 = 25; int num4 = 5; fResult = (double)num4/num1 ; 1.4 2.4.0 3.5 4.0 5.error

17 float fResult = 0; int num1 = 25; int num4 = 5; fResult = (float)num4/num1; 1.4 2.4.0 3.5 4.0.2 5.error

18 int num3 = 21; int num4 = 5; int iResult =0; int iResult = num3%num4; 1.4 2.0 3.1 4.2 5.error

19 I like this class. 1.Yes 2.No

20 I am learning UNIX 1.Yes 2.No

21 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.

22 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

23 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.

24 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.

25 String s = “Hello World”; System.out.print(s.length( )); //what will be printed? 1.10 2.11 3.12 4.I’m sleeping…zzzz

26 String s = “Hello World”; System.out.print(s.indexOf(‘a’)); //what will be printed? 1.There will be an error 2.0 3.-1 4.11

27 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!!!

28 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

29 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

30 We import packages (Java libraries) so that we do not have to re-invent the wheel. 1.True 2.False

31 When using the DecimalFormat class, using # and using 0 is the same 1.True 2.False

32 When using the DecimalFormat we can even add units to the numbers that we are formatting 1.True 2.False

33 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

34 Random gen = new Random( ); int num; num = gen.nextInt(20); //will generate a number between: 1.0 and 19 2.0 and 20 3.1 and 19 4.1 and 20 5.Can’t count now. Java is zero based

35 Random gen = new Random( ); int num; num = gen.nextInt(20)+5; //will generate a number between: 1.5 and 25 2.4 and 19 3.5 and 25 4.5 and 24 5.4 and 25

36 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?


Download ppt "ICS 111 Midterm 1 Review. This class is ICS111 1.True 2.False."

Similar presentations


Ads by Google