programming languages Online Quiz - 239

programming languages Online Quiz - 239

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

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

  1. Errors
  2. Exceptions
  3. Both errors and exceptions
  4. Neither.
Question 2 Multiple Choice (Single Answer)

Both class Error and class Exception are children of this parent:

  1. Throwable
  2. Catchable
  3. Runable
  4. Problem
Question 3 Multiple Choice (Single Answer)

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.
Question 4 Multiple Choice (Single Answer)

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

  1. ArithmeticException
  2. RunTimeException
  3. NumberFormatException
  4. NumberError
Question 5 Multiple Choice (Single Answer)

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.
Question 6 Multiple Choice (Single Answer)

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.
Question 7 Multiple Choice (Single Answer)

Which of the following lists exception types from MOST specific to LEAST specific?

  1. Error, Exception
  2. Exception, RunTimeException
  3. Throwable, RunTimeException
  4. ArithmeticException, RunTimeException
Question 8 Multiple Choice (Single Answer)

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, exactly if there were no try{} block.
  3. The program halts immediately.
  4. The program ignores the exception.
Question 9 Multiple Choice (Single Answer)

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.
Question 10 Multiple Choice (Single Answer)

When is a finally{} block executed?

  1. Always after execution has left a try{} block, no matter for what reason.
  2. Only when an unhandled exception is thrown in a try{} block.
  3. Only when any exception is thrown in a try{} block.
  4. Always just as a method is about to finish.
Question 11 Multiple Choice (Single Answer)

The correct set of sequence for file operations for a file say 'test'

  1. lseek(), open(), write(), close()
  2. open(), write(), lseek(), close()
  3. open(), lseek(), open(), , write() close()
  4. None
Question 12 Multiple Choice (Single Answer)

Difference between fork() & vfork()

  1. vforlk() allows more one child process to be created simaltaneously whereas for() allows only one
  2. vfork() retains same PID for child & parent known as virtual PID
  3. vfork() suspends the parent process until child process exits
  4. fork() & vfork() are same
Question 13 Multiple Choice (Single Answer)

How can I get/set an environment variable from a program?

  1. getenv(), setenv()
  2. getenv(), putenv()
  3. readenv(), writeenv()
  4. You cannot environmement variables inside a program
Question 14 Multiple Choice (Single Answer)

What does alarm() do

  1. Wakes up kernel from sleeping
  2. Wakes up devices from sleeping
  3. Invokes a kernel to send SIGALARM to the calling process
  4. Invokes a kernel to send SIGALARM to the registered process
Question 15 Multiple Choice (Single Answer)

What is a shared memory

  1. A memeory shared between kernel & devices
  2. A memory shared between root user and ordinary user
  3. A memory shared across processes
  4. Harddisk
Question 16 Multiple Choice (Single Answer)

What is a zombie interval?

  1. The interval between child terminating and the parent calling wait()
  2. The interval between parent terminating and the child calling popen()
  3. The interval between parent terminating and the child termination
  4. None
Question 17 Multiple Choice (Single Answer)

Why do processes never decrease in size?

  1. They never releases the memory utilized
  2. They release the memory but kernel does not use them
  3. Since they are running
  4. It’s a false statement
Question 18 Multiple Choice (Single Answer)

How can I find out if someone else has a file open?

  1. Its not possible
  2. use isused() function
  3. Try to open file with locking enabled
  4. Try to write the file after opening
Question 19 Multiple Choice (Single Answer)

How do I `lock' a file?

  1. Use filelock()
  2. use lockfile()
  3. Use lockfd()
  4. use fcntl()
Question 20 Multiple Choice (Single Answer)

How do I find the size of a file inside a program?

  1. Use ls -l
  2. Use sizeof()
  3. Use filesize()
  4. Use fstat()