ADBRITE ads links
You are here: CodeIdol.com > Java > Programmer's Guide to Java Certification > Control Flow, Exception Handling, And Assertions
Programmer's Guide to Java Certification
| Exam Objectives
Write code using if and switch statements, and identify legal argument types for these statements.Write code using all forms of loops, including labeled and...
|
|
| Overview of Control Flow Statements
Control flow statements govern the flow of control in a program during execution, that is, the order in which statements are...
|
|
| Java provides selection statements that allow the program to choose between alternative actions during execution. The choice is based on criteria specified in the selection...
|
|
| Review Questions
5.1
What will be the result of attempting to compile and run the following class?
public class IfTest {
public static void main(String[]...
|
|
| Iteration Statements
Loops allow a block of statements to be executed repeatedly (i.e., iterated). A boolean condition (called the loop condition) is commonly used to determine...
|
|
| Java provides six language constructs for transferring control in a program:
breakcontinuereturntry-catch-finallythrowassert
This section discusses the first three statements, and the remaining statements are discussed in subsequent...
|
|
| 5.5
What will be the result of attempting to compile and run the following code?
class MyClass {
public static void main(String[] args) {...
|
|
| An exception in Java is a signal that indicates the occurrence of some important or unexpected condition during execution. For example, a requested file cannot...
|
|
| Exception Types
Exceptions in Java are objects. All exceptions are derived from the java.lang. Throwable class. Figure shows a partial hierarchy of classes derived from the...
|
|
| try, catch, and finally
The mechanism for handling execeptions is embedded in the try-catch-finally construct, which has the following general form:
try {...
|
|
| throw
Earlier examples in this chapter have shown how an exception is thrown implicitly during execution. A program can explicitly throw an exception using the...
|
|
| throws
A throws clause can be specified in the method protoype.
someMethod() throws <ExceptionType1>, <ExceptionType2>,, <ExceptionTypen> { }
Each <ExceptionTypei> declares a checked exception. The compiler enforces that the checked...
|
|
| 5.15
Which digits, and in which order, will be printed when the following program is run?
public class MyClass {
public static void main(String[]...
|
|
| in Java can be used to document and validate assumptions made about the state of the program at designated locations in the code. Each assertion...
|
|
| Review Questions
5.24
Assuming assertions are enabled, which of these assertion statements will throw an error?
Select the two correct answers.
assert true : true;assert true : false;assert false...
|
|
| Chapter Summary
The following information was included in this chapter:
explanation of the selection statements:
if, if-else, switch
explanation of the iteration statements:
for, while, do-while
explanation of the...
|
|
| Programming Exercises
5.1
Create different versions of a program that finds all the primes below 100. Create one version that uses only the for loop (i.e., no...
|
|
You are here: CodeIdol.com > Java > Programmer's Guide to Java Certification > Control Flow, Exception Handling, And Assertions
|
|
Related tags
Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......
|
|