Midterm II - PowerPoint PPT Presentation

About This Presentation
Title:

Midterm II

Description:

The Scanner may throw the following exception. InputMismatchException. StringOutOfBoundsException ... This changed to fix a typo. String s = 'JAVA'; int x ... – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 24
Provided by: blanc9
Learn more at: http://www2.hawaii.edu
Category:
Tags: midterm | scanner | slide

less

Transcript and Presenter's Notes

Title: Midterm II


1
Midterm II
  • ICS111

2
Two Classes used to read user input
  1. Scanner
  2. BufferedReader
  3. StringReader
  4. 1 and 2
  5. 1 and 3

3
The BufferedReader may throw the following
exception
  1. InputMismatchException
  2. StringOutOfBoundsException
  3. NumberFormatException
  4. IndexOutOfBoundsException
  5. None

4
The Scanner may throw the following exception
  1. InputMismatchException
  2. StringOutOfBoundsException
  3. NumberFormatException
  4. IndexOutOfBoundsException
  5. None

5
Integer.parseInt throws the following exception
  1. InputMismatchException
  2. StringOutOfBoundsException
  3. NumberFormatException
  4. IndexOutOfBoundsException
  5. None

6
String s JAVAint x s.charAt(-1)returns
This slide changed to fix a typo
  1. InputMismatchException
  2. IndexOutOfBoundsException
  3. NumberFormatException
  4. Nothing, it is blank
  5. None of the above

7
String s JAVAint x s.charAt(2)returns
  1. InputMismatchException
  2. A
  3. V
  4. StringOutOfBoundsException
  5. Nothing, it is blank
  6. None of the above

8
if(ilt20igt25)
  1. True for all numbers between 20 and 25
  2. True for all numbers between 21 and 24
  3. True for all numbers less than 20 and greater
    than 25
  4. Never true

9
if(ilt20igt25)
  1. True for all numbers between 20 and 25
  2. True for all numbers between 21 and 24
  3. True for all numbers less than 20 and greater
    than 25
  4. Never True

10
if(igt20ilt25)
  1. True for all numbers less than 20 and greater
    than 25
  2. True for all numbers between 21 and 24
  3. True for all numbers
  4. Never true

11
if(igt20ilt25)
  1. True for all numbers less than 20 and greater
    than 25
  2. True for all numbers between 21 and 24
  3. True for all numbers
  4. Never true

12
How many times will the loop execute?for(i0
ilt5 ii2)
  1. Will never execute
  2. Will execute 2 times
  3. Will execute 3 times
  4. Will execute 4 times
  5. Infinite Loop

13
How many times will the loop execute?for(i0
igt5 ii2)
  1. Will never execute
  2. Will execute 2 times
  3. Will execute 3 times
  4. Will execute 4 times
  5. Infinite Loop

14
How many times will the loop execute?for(i0
igt5 ii-1)
  1. Will never execute
  2. Will execute 2 times
  3. Will execute 3 times
  4. Will execute 4 times
  5. Infinite Loop

15
How many times will the loop execute?int x
2while(xlt5) xx(x2)
  1. Will never execute
  2. Will execute 2 times
  3. Will execute 3 times
  4. Will execute 4 times
  5. Infinite Loop

16
How many times will the loop execute?int x
3while(xlt5) xx(x2)
  1. Will never execute
  2. Will execute 2 times
  3. Will execute 3 times
  4. Will execute 4 times
  5. Infinite Loop

17
How many times will the loop execute?int x
18while(xgt5) xx-(x/3)
  1. Will never execute
  2. Will execute 2 times
  3. Will execute 3 times
  4. Will execute 4 times
  5. Infinite Loop

18
Switch statements work with
  1. int
  2. char
  3. String
  4. doolean
  5. Any primitive data type
  6. Only 1 and 2
  7. Only 1,2 and 3

19
switch(x) case 1 case 2 case 3 xx1
case 4 xx2 default xx-5
Runing this code with x 2, After executing the
switch statement What will be the value of x?
  1. 2
  2. 3
  3. 4
  4. 5
  5. 0

20
switch(x) case 1 xx1
break case 2 xx2 break
case 3 xx1 break default
xx-5
Runing this code with x 7, After executing the
switch statement What will be the value of x?
  1. 2
  2. 3
  3. 4
  4. 5
  5. 0

21
switch(x) case 1 xx1 case 2 xx2
break case 3 xx1 default
xx-5
Runing this code with x 2, After executing the
switch statement What will be the value of x?
  1. 2
  2. 3
  3. 4
  4. 5
  5. 0

22
switch(x) case 1 xx1 case 2 xx2
break case 3 xx1 default
xx-5
Runing this code with x 1, After executing the
switch statement What will be the value of x?
  1. 2
  2. 3
  3. 4
  4. 5
  5. 0

23
String s1JAVAString s2javAboolean
areEqualfalseareEqual s1.equals(s2)
areEqual is
  1. True
  2. False
Write a Comment
User Comments (0)
About PowerShow.com