0
Alien head

programming languages Online Quiz - 208

Description: programming languages Online Quiz - 208
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Why can't the whole program just consist of the one line that does the painting ?

  1. In Java, to create an applet, you can't call on functions without defining a class to call them.

  2. To appear on the web, Java must use an applet, and without first defining a class, you won't be painting onto anything.

  3. The drawString function is not defined without the "import" statements at the top.

  4. All of the above.


Correct Option: D

Java runs on _______.

  1. Windows

  2. Unix/Linux

  3. Mac

  4. All of the Above


Correct Option: D

What is an Applet ?

  1. Type of computer

  2. A Java program that is run through a web browser

  3. An interactive website

  4. A type of fruit


Correct Option: B

What is Java (in regard to Computer Science) ?

  1. A type of coffee

  2. An object-oriented programming language

  3. An interactive website

  4. None of the above


Correct Option: B

When is a finally{} block executed?

  1. Only when an unhandled exception is thrown in a try{} block.

  2. Only when any exception is thrown in a try{} block.

  3. Always after execution has left a try{} block, no matter for what reason.

  4. Always just as a method is about to finish.


Correct Option: C

How many finally{} blocks may there be in a try/catch structure?

  1. There must always be one, following the last catch{} block.

  2. There can be zero or one immediately after each catch{} block.

  3. There can be zero or one, following the last catch{} block.

  4. There can be any number, following the last catch{} block.


Correct Option: C

What happens in a method if an exception is thrown in a try{} block and there is NO MATCHING catch{} block?

  1. This is not legal, so the program will not compile.

  2. The method throws the exception to its caller if there were no matching catch{} block.

  3. The program halts immediately.

  4. The program ignores the exception.


Correct Option: B

Which statement is FALSE about catch{} blocks?

  1. There can be several catch{} blocks in a try/catch structure.

  2. The catch{} block for a child exception class must PRECEED that of a parent execption class.

  3. The catch{} block for a child exception class must FOLLOW that of a parent execption class.

  4. If there is no catch{} block there must be a finally{} block.


Correct Option: C

Which statement is FALSE about the try{} block?

  1. Some of the statements in a try{} block will never throw an exception.

  2. The statements in a try{} block may throw several types of exception.

  3. The try{} block can not contain loops or branches.

  4. The try{} block must appear before the catch{} blocks.


Correct Option: C

Is this Legal? Class ExceptionA extends Exception {} class ExceptionB extends ExceptionA {} public class Test{ void thrower() throws ExceptionA{ throw new ExceptionA(); } public static void main(String[] args){ Test t = new Test(); try{t.thrower();} catch(ExceptionB e) {} } }

  1. True

  2. False


Correct Option: B

What type of exception is thrown by parseInt() if it gets illegal data?

  1. ArithmeticException

  2. RunTimeException

  3. NumberFormatException

  4. NumberError


Correct Option: C

If a catch handler is written to catch exception objects of a superclass type, it can also catch all objects of that class's subclasses.

  1. True

  2. False


Correct Option: B

A try block must always be followed by one or more catch blocks

  1. True

  2. False


Correct Option: B

Java throws ------------------- when division by zero in integer arithmetic occurs

  1. an IntegerArithmeticException

  2. an ArithmeticException

  3. a DivideByZeroException

  4. a NumberFormatException


Correct Option: B

Class Exception is the superclass of all exceptions

  1. True

  2. False


Correct Option: B

Is a program required to catch all exceptions that might happen?

  1. No. You can write a program to catch just the exceptions you want.

  2. No. But if a program catches one type of exception it must catch all other types as well.

  3. Yes. If a program is not written to catch all exceptions it will not compile.

  4. Yes. A program can not do I/O unless it catches all exceptions.


Correct Option: A

From which problems is it possible for a program to recover?

  1. Errors

  2. Exceptions

  3. Both errors and exceptions

  4. Neither


Correct Option: B

Java guarantees that a finally clause (if one is present) will execute even if a try block exits by using a return, break or continue statement.

  1. True

  2. False


Correct Option: B

By convention, all exception-class names should end with the word Exception

  1. True

  2. False


Correct Option: B

Identify the true statements.

  1. Checked exceptions must be explicitly caught or propagated(declared Thrown)

  2. Unchecked exceptions must be explicitly caught or propagated(declared Thrown)

  3. Checked exceptions in Java extend the java.lang.Exception class

  4. Unchecked exceptions extend the java.lang.RuntimeException class


Correct Option: A,C,D
+ View questions