1 / 36

ICS 111

0. ICS 111. Midterm 1 Review. :00. This class is ICS111. 0. True False. :00. Variable names should be descriptive and readable. 0. True False. :00. line of Java code “// System.out.println("Hello");” will. 0. do nothing cause "Hello" to be output cause a syntax error

iola-pratt
Download Presentation

ICS 111

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 0 ICS 111 Midterm 1 Review

  2. :00 This class is ICS111 0 • True • False

  3. :00 Variable names should be descriptive and readable 0 • True • False

  4. :00 line of Java code “// System.out.println("Hello");” will 0 • do nothing • cause "Hello" to be output • cause a syntax error • cause "(Hello)" to be output • there is no way to know without executing this line of code

  5. :00 Is this a valid Java identifier?RESULT 0 • Yes • No • Yes but it doesn’t follow the Java coding standards • What is an identifier?

  6. :00 Is this a valid Java identifier?black&white 0 • Yes • No • Yes but it doesn’t follow the Java coding standards

  7. :00 The // comment runs to the end of the line only. 0 • Yes • No

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

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

  10. :00 What value is contained in the int variable size after this is executed:size = 18;size = size + 12;size = size/4; 0 • This will generate an error • 30 • 7 • 7.3 • 8

  11. :00 What value is contained in the float variable depth after the following statements are executed?depth = 2.4;depth = 20 – depth; 0 • 17 • 18 • 17.6 • There will be an error

  12. :00 int iResult;int num1 = 25;int num4 = 5;iResult = num1/num4; 0 • 4 • 4.0 • 5 • 0 • No idea 

  13. :00 int iResult;int num1 = 25;int num4 = 5;iResult = num4/num1; 0 • 4 • 0.2 • 5 • 0 • No idea , again…

  14. :00 float fResult = 0;int num1 = 25;int num4 = 5;fResult = num1/num4; 0 • 4 • 4.0 • 5 • 0 • error

  15. :00 float fResult = 0;int num1 = 25;int num4 = 5;fResult = num4/num1; 0 • 4 • 4.0 • 5 • 0 • error

  16. :00 float fResult = 0;int num1 = 25;int num4 = 5;fResult = (double)num4/num1; 0 • 4 • 4.0 • 5 • 0 • error

  17. :00 float fResult = 0;int num1 = 25;int num4 = 5;fResult = (float)num4/num1; 0 • 4 • 4.0 • 5 • 0.2 • error

  18. :00 int num3 = 21;int num4 = 5;int iResult =0;int iResult = num3%num4; 0 • 4 • 0 • 1 • 2 • error

  19. :00 I like this class. 0 • Yes • No

  20. :00 I am learning UNIX 0 • Yes • No

  21. :00 I will recommend my friends to take this class 0 • Yes • No way Jose • I’m waiting for the first midterm exam result.

  22. :00 String s = “Hello World”;s.substring(3);System.out.print(s);//what will be printed? 0 • llo World • lo World • l • Hello World

  23. :00 String s = “Hello World”;System.out.print(s.substring(3));//what will be printed? 0 • llo World • lo World • l • I have no clue.

  24. :00 String s = “Hello World”;System.out.print(s.substring(0));//what will be printed? 0 • Hello World • elloWord • An error will occur • I don’t want to think right now.

  25. :00 String s = “Hello World”;System.out.print(s.length( ));//what will be printed? 0 • 10 • 11 • 12 • I’m sleeping…zzzz

  26. :00 String s = “Hello World”;System.out.print(s.indexOf(‘a’));//what will be printed? 0 • There will be an error • 0 • -1 • 11

  27. :00 String s = “Hello World”;System.out.print(s.substring(3,4));//what will be printed? 0 • llo World • lo World • l • Please, stop it!!!

  28. :00 String s = “Hello World”;System.out.print(s.charAt(0));//what will be printed? 0 • H • d • l • There will be an error

  29. :00 String s = “Hello World”;System.out.print(s.charAt(-1));//what will be printed? 0 • H • d • A blank • There will be an error An IndexOutOfBoundsException

  30. :00 We import packages (Java libraries) so that we do not have to re-invent the wheel. 0 • True • False

  31. :00 When using the DecimalFormat class, using # and using 0 is the same 0 • True • False

  32. :00 When using the DecimalFormat we can even add units to the numbers that we are formatting 0 • True • False

  33. :00 Random gen = new Random( );int num;num = gen.nextInt( ); 0 • Will generate a number between 0 and the highest int number. • Will generate a number within the whole int range • Will generate a number between 0 and 1

  34. :00 Random gen = new Random( );int num;num = gen.nextInt(20);//will generate a number between: 0 • 0 and 19 • 0 and 20 • 1 and 19 • 1 and 20 • Can’t count now. Java is zero based

  35. :00 Random gen = new Random( );int num;num = gen.nextInt(20)+5;//will generate a number between: 0 • 5 and 25 • 4 and 19 • 5 and 25 • 5 and 24 • 4 and 25

  36. :00 Are you ready for the midterm now? 0 • Yes • No • Just a little bit • Now I know that I don’t know. • What midterm?

More Related