What is try-catch block?

1 Answer

Answer :

A: try-catch block is a way to handle exceptions in Java. try contains a block of statements to check for any error. If any error occurs within the try block, it is trapped. Further a report is passed to the exception handler about the error, which is done by the catch block.

Related questions

Description : Can we have only “try” block without “catch” block in C#?

Last Answer : Yes, we can have only try block without catch block.

Description : Which of the following files will displayed by this command cat *ch* A. patch B. catch C. .ch D. All of the above E. None of the above

Last Answer : D. All of the above

Description : Which one of the following is not a software myth? (A) Once we write the program and get it to work, our job is done. (B) Project requirements continually change, but ... not understand how to control software projects internally, it will invariably struggle when it outsources software projects.

Last Answer : (D) If an organization does not understand how to control software projects internally, it will invariably struggle when it outsources software projects.

Description : Suppose d = { john :40, peter :45}, what happens when we try to retrieve a value using the expression d[ susan ]? a) Since susan is not a value in the set, Python raises a KeyError ... Python raises a KeyError exception d) Since susan is not a key in the set, Python raises a syntax error

Last Answer : c) Since “susan” is not a key in the set, Python raises a KeyError exception

Description : Early success: What are practical examples that show it's better to do your best early, rather than try to catch up in the middle or end?

Last Answer : Well, this isn't really a real life example, But the story of the Tortoise and the Hare seems to teach this lesson pretty well. But if your entertaining college students, You might want to go with ... frat guy who both had to study for the same statistics exam. and well you can see the parallels.

Description : I am present on a winter's day, Surprise me and I am taken away. The faster you run, the harder I am to catch, Try all you can, I am not easy to snatch. I am always with you, somewhere in the ... a sound. Keep your head cool and you will finally see, That I am inside you. What could I be? -Riddles

Last Answer : Your breath.

Description : Can multiple catch blocks be executed for a single try statement?

Last Answer : No. Once the proper catch block processed, control is transferred to the finally block (if there are any). 

Description : Write some try…catch…finally code.

Last Answer : // try-catch-finally using System; public class TCFClass { public static void Main () { try { throw new NullReferenceException(); } catch(NullReferenceException e) { Console.WriteLine("{0} exception 1 ... ("exception 2."); } finally { Console.WriteLine("finally block."); } } }

Description : Can multiple catch blocks be executed for a single try statement?

Last Answer : No. Once the proper catch block processed, control is transferred to the finally block (if there are any).

Description : The Keywords - try, catch, and finally are typically used in the sequence: a) Finally, Try and Catch b) Try, Finally and Catch c) Try, Catch and Finally d) Catch, Try and Finally e) None of The Above

Last Answer : c) Try, Catch and Finally

Description : How does a try statement determine which catch clause should be used to handle an exception?

Last Answer : Ans. When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exception is executed. The remaining catch clauses are ignored.

Description : Write the syntax of try-catch-finally blocks.

Last Answer : try{ //Statements to be monitored for any exception } catch(ThrowableInstance1 obj) { //Statements to execute if this type of exception occurs } catch(ThrowableInstance2 obj2) { //Statements }finally{ //Statements which should be executed even if any exception happens }

Description : Suppose your colleague either commits theft or torn out your postage from school due to jealously. How would you overcome this problem? Options: A) You catch the culprit red-handed and abuse him B) You try ... him a lesson C) Once you catch him and warn him severely D) You insult him in public

Last Answer : C) Once you catch him and warn him severely 

Description : What is finally block?

Last Answer : A: finally block contains statements which are to be executed irrespective of any errors. It is used along with the try-catch block.

Description : A variable is defined within a block in a body of a function. Which of the following are true? A) It is visible throughout the function. B) It is visible from the point of definition to the end ... visible from the point of definition to the end of the block. D) It is visible throughout the block.

Last Answer : D) It is visible throughout the block.

Description : A UNIX file system has 1 KB block size and 4-byte disk addresses. What is the maximum file size if the inode contains ten direct block entries, one single indirect block entry, one double indirect block entry and one triple indirect block entry? (A) 30 GB (B) 64 GB (C) 16 GB (D) 1 GB

Last Answer : (C) 16 GB

Description : Assuming that the disk head is located initially at 32, find the number of disk moves required with FCFS if the disk queue of I/O block requests are 98, 37, 14, 124, 65, 67: (A) 310 (B) 324 (C) 320 (D) 321

Last Answer : (D) 321

Description : How much space will be required to store the bit map of a 1.3 GB disk with 512 bytes block size ? (A) 332.8 KB (B) 83.6 KB (C) 266.2 KB (D) 256.6 KB

Last Answer : (A) 332.8 KB

Description : Consider a disk queue with request for input/output to block on cylinders  98, 183, 37, 122, 14, 124, 65, 67  in that order. Assume that disk head is initially positioned at cylinder 53 and moving ... and 252 cylinders (B) 640 and 236 cylinders (C) 235 and 640 cylinders (D) 235 and 252 cylinders

Last Answer : Answer: 236 and 208 cylinders Explanation: SSTF Initial head position =53 The closest queue to initial head position=65 head moves from 53 to 65=12 head moves from 65 to 67=2 head moves from 67 ... 122=24 head moves from 122 to 124=2 head moves from 124 to 183=59 Total head movement=208 

Description : ................. maintains the list of free disk blocks in the Unix file system. (A) I-node (B) Boot block (C) Super block (D) File allocation table

Last Answer : (C) Super block 

Description : Which of the following conditions does not hold good for a solution to a critical section problem ? (A) No assumptions may be made about speeds or the number of CPUs. (B) No two processes ... critical section may block other processes. (D) Processes do not wait forever to enter its critical section.

Last Answer : (C) Processes running outside its critical section may block other processes. 

Description : In ............ allocation method for disk block allocation in a file system, insertion and deletion of blocks in a file is easy. (A) Index (B) Linked (C) Contiguous (D) Bit Map

Last Answer : (B) Linked

Description : In the indexed scheme of blocks to a file, the maximum possible size of the file depends on: (A) The number of blocks used for index, and the size of index (B) Size of Blocks and size of Address (C) Size of Index (D) Size of Block

Last Answer : (A) The number of blocks used for index, and the size of index

Description : Which of the following is/are restriction(s) in classless addressing ? (A) The number of addresses needs to be a power of 2. (B) The mask needs to be included in the address to define the block. (C) The starting address must be divisible by the number of addresses in the block. (D) All of the above

Last Answer : (D) All of the above

Description : Loop unrolling is a code optimization technique: (A) that avoids tests at every iteration of the loop (B) that improves performance by decreasing the number of instructions in a basic block. ... loops with outer loops (D) that reorders operations to allow multiple computations to happen in parallel.

Last Answer : (A) that avoids tests at every iteration of the loop

Description : Consider a disk with 16384 bytes per track having a rotation time of 16 msec and average seek time of 40 msec. What is the time in msec to read a block of 1024 bytes from this disk? (A) 57 msec (B) 49 msec (C) 48 msec (D) 17 msec

Last Answer : Answer: B

Description : Which of the following information about the UNIX file system is not correct? (A) Super block contains the number of i-nodes, the number of disk blocks, and the start of the list of free disk blocks. (B ... Each i-node is 256-bytes long. (D) All the files and directories are stored in data blocks. 

Last Answer : (C) Each i-node is 256-bytes long.

Description : In ............. method, the word is written to the block in both the cache and main memory, in parallel. (A) Write through (B) Write back (C) Write protected (D) Direct mapping

Last Answer : (A) Write through 

Description : The order of a leaf node in a B+ tree is the maximum number of children it can have. Suppose that block size is 1 kilobytes, the child pointer takes 7 bytes long and search field value takes 14 bytes long. The order of the leaf node is ............ (1) 16 (2) 63 (3) 64 (4) 65

Last Answer : Answer: All

Description : Government try to block all porno sites? What's your thought?

Last Answer : Big Brother.