Given the code fragment:
What is the result?
A. Reading Card
Checking Card
B. Compilation fails only at line n1.
C. Compilation fails only at line n2.
D. Compilation fails only at line n3.
E. Compilation fails at both line n2 and line n3.
Given the code fragment:
What is the result?
A. Reading Card
Checking Card
B. Compilation fails only at line n1.
C. Compilation fails only at line n2.
D. Compilation fails only at line n3.
E. Compilation fails at both line n2 and line n3.
D
void readCard(int cardNo) throws Exception{
System.out.println(“Read card”);
}
void checkCard(int cardNo) throws RuntimeException{
System.out.println(“Check card”);
}
public static void main(String[] args) {
int cardNo=12344;
Q131 ex = new Q131();
ex.checkCard(cardNo);
// ex.readCard(cardNo);//not compile u have to put throws Exception in main method (declare or handel check Exception )
}