© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

Home Placements Interview Questions Java Interview Questions And Answers Java Interview Questions On Flow Control and Exception Handling ▼

Java Interview Questions On Flow Control and Exception Handling

32. What is the output of the following program if you compile and run?
outer: for (int i = 0; i < 2; i++ ) {
for ( int j = 0; j < 3; j++ ) {
if ( i == j ) {
continue outer;
}
System.out.println("The value of i is: " + i );
System.out.println("The value of i is: " + j);
}
}
[a] The value of i is: 0
The value of j is: 0
[b] The value of i is: 0
The value of j is: 1
[c] The value of i is: 0
The value of j is: 2
[d] The value of i is: 1
The value of j is: 0
[e] The value of i is: 1
The value of j is: 1
[f] The value of i is: 1
The value of j is: 2

Answer
[d] The value of i is: 1

The value of j is: 0

33. What is the result of compiling the following code?
class MyExp {
void MyMethod() throws IOException, EOFException {
//............
}
}
class MyExp1 extends MyExp {
void MyMethod() {
//..........
}
}
public class MyExp2 extends MyExp1 {
void MyMethod() throws IOException {
//.........
}
}
[a] Compile time error
[b] No compile time error
[c] Run-Time error
[d] MyMethod() cannot throw an exception in MyExp2 class

Answer
[a] Compile time error

34. Select all correct answers?
public class ExpTest {
public static void main ( String[] args ) {
try {
MyMethod();
} catch ( Exception e) {
}
}
static void MyMethod() {
try {
System.out.println("a");
} catch ( ArithmeticException ae) {
System.out.println("b");
} finally {
System.out.println("c");
}
System.out.println("d");
}
}
[a] a
[b] b
[c] c
[d] d

Answer
[a] a
[c] c
[d] d

Previous Next
1 2 3 4 5 6 7 8 9
SLogix Student Projects
bottom