Catch me if you can

AVAILABLE

"Hi, Amigo. Here are some interesting tasks that involve catching exceptions."

5
Task
Java Syntax,  level 9,  lesson 6
Locked
Exception when working with numbers
Esteemed colleagues, things are getting serious. We're starting sting operation to catch exceptions. The secret CodeGym center has sent the following task, and I quote: "Catch (and display the type of) the exception that occurs when the following code is executed: int a = 42 / 0;". Note: Complete this task immediately.
5
Task
Java Syntax,  level 9,  lesson 6
Locked
Exception while working with strings
In Java, an exception is an object. And it has a type, of course. This all seems vague until you start working with them. Practice will dispel the uncertainty. Be more confident in catching exceptions: catch and display the exception (indicating its type) that occurs when executing the following code: String s = null; String m = s.toLowerCase().
5
Task
Java Syntax,  level 9,  lesson 6
Locked
Exception when working with arrays
We're mastering the mechanism for handling errors in the program. By that I mean exceptions. This time, your task is to catch exceptions when working with arrays. An application has the following lines of code: int[] m = new int[2]; m[8] = 5; Catch the exception that occurs when this code is executed, and then display it on the screen and indicate its type.
5
Task
Java Syntax,  level 9,  lesson 6
Locked
Exception when working with List collections
By the ninth level, we've already got some idea of List collections, and exceptions. Let's bring this knowledge together: catch exceptions when executing the following code: ArrayList<String> list = new ArrayList<String>(); String s = list.get(18); Catch and display the exception on the screen, indicating its type.
5
Task
Java Syntax,  level 9,  lesson 6
Locked
Exception when working with Map collections
We have some questionable code. It's time to deploy an agent to intercept (catch) exceptions. Here's the code: HashMap<String, String> map = new HashMap<String, String>(null); map.put(null, null); map.remove(null); Agent, your task, as usual, is to catch the exception and display it on the screen. Don't forget to only display the exception type.
5
Task
Java Syntax,  level 9,  lesson 6
Locked
Exception when working with numbers
Another task about catching exceptions arrived today at the secret CodeGym center. This time, we have to catch an exception and immediately display it on the screen. Don't forget to indicate its type. The exception in question will occur when the following code is executed: int num = Integer.parseInt("XYZ"); System.out.println(num).

"Here's a tip: write your program, see what sort of exceptions occur, and then change the code to catch them."

Comments (13)
  • Popular
  • New
  • Old
You must be signed in
Syed Tayyab ul MazharLevel 11 , Karachi
Friday, 04:37
I saw the tip when i arrived at the last task LOL.
allthemoreLevel 22
5 May, 09:48
Do the tasks in Idea. Sometimes (not always) it makes suggestions which exception will occur.
Ed MaphisLevel 18 , Painesville
26 May, 23:19
That's what I did.
Oleg VanyushkinLevel 18 , St.-Petersburg
9 April, 08:29
Just catched everything.
Philip ObiorahLevel 9 , Port - Harcourt
8 April, 12:56
sweet
27 March, 09:55
Tip: Read the tip at the end before starting to work on the tasks : )
// Java PoserLevel 18 , Cincinnati
25 March, 22:46
Nice Doggo!!
HashiramaLevel 20 , Port-Harcourt
26 January, 11:46
I think this one is the simplest set of tasks so far. What do you think guys?
kapilLevel 12 , delhi
8 February, 09:46
right
// Java PoserLevel 18 , Cincinnati
25 March, 22:49
Lol finally some tasks to build my confidence!
Jesús de LleraLevel 19 , Badajoz
16 April, 12:14
Totalmente de acuerdo!
Ops guyLevel 17 , Round Rock, TX
30 April, 21:20
yup
Ronnie StephensLevel 10 , Lake City
14 May, 23:08
After Level 8, these tasks were a nice non-frustrating break.