- Home
- Placement
- Programming
- Exception handling
- Array
- Data Types
- Functions
- Loop & Control Statements
- Operators & Expressions
- Pointer
- Preprocessor
- Storage Classes
- Structure & Union
- Variables & Constants
- Classes and Objects
- Consructors and Destructors
- Exception handling
- File Handling
- Function Overloading
- Inheritance
- Operator Overloading
- Polymorphism
- Templates
C Language
C++ language
JAVA
-
-
( 1 ) Which of these points will be valid If superclass method does not throw any exception
- 1) overridden method of subclass can throw any RuntimeException
- 2) overridden method of subclass cannot throw any checked exception
- 3) overridden method of subclass may not throw any exception.
- 4) All of the above
-
Show Answer Report Discussion in forumAnswer : 4) All of the above
Solution :
discussion
Answer : 4) All of the above
-
-
-
( 2 ) FileNotFoundException
- 1) Is a subclass/extends IOException
- 2) Is a Compile time exception
- 3) Found in java.io package
- 4) All of the above
-
Show Answer Report Discussion in forumAnswer : 4) All of the above
Solution :
discussion
Answer : 4) All of the above
-
-
-
( 3 ) Which method is used to print the description of the exception?
- 1) printStackTrace()
- 2) printExceptionMessage()
- 3) printStackMessage()
- 4) printExceptionTrace()
-
Show Answer Report Discussion in forumAnswer : 1) printStackTrace()
Solution :
discussion
Answer : 1) printStackTrace()
-
-
-
( 4 ) Which of these keywords is used to by the calling function to guard against the exception that is thrown by called function?
- 1) try
- 2) throw
- 3) throws
- 4) catch
-
Show Answer Report Discussion in forumAnswer : 3) throws
Solution : If a method is capable of causing an exception that it does not handle. It must specify this behaviour the behaviour so that callers of the method can guard themselves against that exception. This is done by using throws clause in methods declaration.
discussion
Answer : 3) throws
-
-
-
( 5 ) In Java programming environment, the throw keyword is used
- 1) to generate exception programmatically
- 2) to throw exception object
- 3) to catch exception object
- 4) None of these
-
Show Answer Report Discussion in forumAnswer : 1) to generate exception programmatically
Solution : In Java throw keyword is used to handle exception programmatically.
discussion
Answer : 1) to generate exception programmatically
-
-
-
( 6 ) In case of multiple catch blocks,______
- 1) The superclass exception must be caught first
- 2) The superclass exception can not caught first
- 3) Either super or subclass can be caught first.
- 4) None of these
-
Show Answer Report Discussion in forumAnswer : 2) The superclass exception can not caught first
Solution :
discussion
Answer : 2) The superclass exception can not caught first
-
-
-
( 7 ) What type of Exceptions can be ignored at compile time?
- 1) Runtime
- 2) Checked
- 3) Both 1 and 2
- 4) None of these
-
Show Answer Report Discussion in forumAnswer : 1) Runtime
Solution :
discussion
Answer : 1) Runtime
-
-
-
( 8 ) What will be the result after the class Test execution?
class A{
public void doA(){
B b = new B();
b.dobB();
System.out.print("doA");
}
}
class B{
public void dobB(){
C c = new C();
c.doC();
System.out.print("doB");
}
}
class C{
public void doC(){
if(true)
throw new NullPointerException();
System.out.print("doC");
}
}
public class Test{
public static void main(String args[]){
try{
A a = new A();
a.doA();
}
catch(Exception ex){
System.out.print("error");
}
}
} - 1) "doCdoBdoA" is printed
- 2) "doAdoBdoC" is printed
- 3) "doBdoAerror" is printed
- 4) "error" is printed
-
Show Answer Report Discussion in forumAnswer : 4) "error" is printed
Solution :
discussion
Answer : 4) "error" is printed
-
-
-
( 9 ) Which of these keywords is used to manually throw an exception?
- 1) try
- 2) finally
- 3) throw
- 4) catch
-
-
-
( 10 ) public class Test{
public static void main(String args[]){
try{
int a = Integer.parseInt("four");
}
}
}
Which exception could be handled by the catch block for above? - 1) IllegalStateException
- 2) NumberFormatException
- 3) ClassCastException
- 4) ArrayIndexOutOfBoundsException
-
Show Answer Report Discussion in forumAnswer : 2) NumberFormatException
Solution :
discussion
Answer : 2) NumberFormatException
-