370 likes | 515 Views
Prepare for your ICS 111 midterm exam with this comprehensive review guide. This resource covers essential Java programming concepts, including variable naming conventions, Java identifiers, comments, and String manipulations. It also includes multiple choice questions with explanations about output generation and formatting methods in Java. Review questions address both basic and complex topics, ensuring you have a solid understanding before the exam. Test your knowledge and readiness for the midterm with this study aid.
E N D
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 • cause "(Hello)" to be output • there is no way to know without executing this line of code
: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?
:00 Is this a valid Java identifier?black&white 0 • Yes • No • Yes but it doesn’t follow the Java coding standards
:00 The // comment runs to the end of the line only. 0 • Yes • No
: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
: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
: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
: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
:00 int iResult;int num1 = 25;int num4 = 5;iResult = num1/num4; 0 • 4 • 4.0 • 5 • 0 • No idea
:00 int iResult;int num1 = 25;int num4 = 5;iResult = num4/num1; 0 • 4 • 0.2 • 5 • 0 • No idea , again…
:00 float fResult = 0;int num1 = 25;int num4 = 5;fResult = num1/num4; 0 • 4 • 4.0 • 5 • 0 • error
:00 float fResult = 0;int num1 = 25;int num4 = 5;fResult = num4/num1; 0 • 4 • 4.0 • 5 • 0 • error
:00 float fResult = 0;int num1 = 25;int num4 = 5;fResult = (double)num4/num1; 0 • 4 • 4.0 • 5 • 0 • error
:00 float fResult = 0;int num1 = 25;int num4 = 5;fResult = (float)num4/num1; 0 • 4 • 4.0 • 5 • 0.2 • error
:00 int num3 = 21;int num4 = 5;int iResult =0;int iResult = num3%num4; 0 • 4 • 0 • 1 • 2 • error
:00 I like this class. 0 • Yes • No
:00 I am learning UNIX 0 • Yes • No
:00 I will recommend my friends to take this class 0 • Yes • No way Jose • I’m waiting for the first midterm exam result.
:00 String s = “Hello World”;s.substring(3);System.out.print(s);//what will be printed? 0 • llo World • lo World • l • Hello World
: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.
: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.
:00 String s = “Hello World”;System.out.print(s.length( ));//what will be printed? 0 • 10 • 11 • 12 • I’m sleeping…zzzz
:00 String s = “Hello World”;System.out.print(s.indexOf(‘a’));//what will be printed? 0 • There will be an error • 0 • -1 • 11
: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!!!
:00 String s = “Hello World”;System.out.print(s.charAt(0));//what will be printed? 0 • H • d • l • There will be an error
: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
:00 We import packages (Java libraries) so that we do not have to re-invent the wheel. 0 • True • False
:00 When using the DecimalFormat class, using # and using 0 is the same 0 • True • False
:00 When using the DecimalFormat we can even add units to the numbers that we are formatting 0 • True • False
: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
: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
: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
: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?