programming languages Online Quiz - 239
programming languages Online Quiz - 239
Questions
From which problems is it possible for a program to recover?
- Errors
- Exceptions
- Both errors and exceptions
- Neither.
Both class Error and class Exception are children of this parent:
- Throwable
- Catchable
- Runable
- Problem
Is a program required to catch all exceptions that might happen?
- No. You can write a program to catch just the exceptions you want.
- No. But if a program catches one type of exception it must catch all other types as well.
- Yes. If a program is not written to catch all exceptions it will not compile.
- Yes. A program can not do I/O unless it catches all exceptions.
What type of exception is thrown by parseInt() if it gets illegal data?
- ArithmeticException
- RunTimeException
- NumberFormatException
- NumberError
Which statement is FALSE about the try{} block?
- Some of the statements in a try{} block will never throw an exception.
- The statements in a try{} block may throw several types of exception.
- The try{} block can not contain loops or branches.
- The try{} block must appear before the catch{} blocks.
Which statement is FALSE about catch{} blocks?
- There can be several catch{} blocks in a try/catch structure.
- The catch{} block for a child exception class must PRECEED that of a parent execption class.
- The catch{} block for a child exception class must FOLLOW that of a parent execption class.
- If there is no catch{} block there must be a finally{} block.
Which of the following lists exception types from MOST specific to LEAST specific?
- Error, Exception
- Exception, RunTimeException
- Throwable, RunTimeException
- ArithmeticException, RunTimeException
What happens in a method if an exception is thrown in a try{} block and there is NO MATCHING catch{} block?
- This is not legal, so the program will not compile.
- The method throws the exception to its caller, exactly if there were no try{} block.
- The program halts immediately.
- The program ignores the exception.
How many finally{} blocks may there be in a try/catch structure?
- There must always be one, following the last catch{} block.
- There can be zero or one immediately after each catch{} block.
- There can be zero or one, following the last catch{} block.
- There can be any number, following the last catch{} block.
When is a finally{} block executed?
- Always after execution has left a try{} block, no matter for what reason.
- Only when an unhandled exception is thrown in a try{} block.
- Only when any exception is thrown in a try{} block.
- Always just as a method is about to finish.
The correct set of sequence for file operations for a file say 'test'
- lseek(), open(), write(), close()
- open(), write(), lseek(), close()
- open(), lseek(), open(), , write() close()
- None
Difference between fork() & vfork()
- vforlk() allows more one child process to be created simaltaneously whereas for() allows only one
- vfork() retains same PID for child & parent known as virtual PID
- vfork() suspends the parent process until child process exits
- fork() & vfork() are same
How can I get/set an environment variable from a program?
- getenv(), setenv()
- getenv(), putenv()
- readenv(), writeenv()
- You cannot environmement variables inside a program
What does alarm() do
- Wakes up kernel from sleeping
- Wakes up devices from sleeping
- Invokes a kernel to send SIGALARM to the calling process
- Invokes a kernel to send SIGALARM to the registered process
What is a shared memory
- A memeory shared between kernel & devices
- A memory shared between root user and ordinary user
- A memory shared across processes
- Harddisk
What is a zombie interval?
- The interval between child terminating and the parent calling wait()
- The interval between parent terminating and the child calling popen()
- The interval between parent terminating and the child termination
- None
Why do processes never decrease in size?
- They never releases the memory utilized
- They release the memory but kernel does not use them
- Since they are running
- It’s a false statement
How can I find out if someone else has a file open?
- Its not possible
- use isused() function
- Try to open file with locking enabled
- Try to write the file after opening
How do I `lock' a file?
- Use filelock()
- use lockfile()
- Use lockfd()
- use fcntl()
How do I find the size of a file inside a program?
- Use ls -l
- Use sizeof()
- Use filesize()
- Use fstat()