Teacher diego

Catch me if you can

Available
Catch me if you can - 1

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

Teacher diego
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.
Teacher diego
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().
Teacher diego
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.
Teacher diego
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.
Teacher diego
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.
Teacher diego
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 (20)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
NikolaosLevel 14 , Vrontados
28 August, 15:48
Great! Keep walking...
Binesh BLevel 10
24 August, 01:48
Nice.!
NoraLevel 17 , Tehran
2 August, 15:17
Collecting those free dark matters
VorisLevel 10 , Tashkent
14 July, 07:33
Too easy for codegym, may be it's a trap.
EwertonLevel 30 , Belo Horizonte
28 June, 19:45
If you use Intellij: 1) You can surround a text with if/while/for/try&catch, just by selecting it and then Ctrl+Alt+T. 2) It informs you about the exception type. It helps a lot, looks almost like cheating haha. Gotta Catch'Em All
Brandon HorvaticLevel 17 , Johannesburg
2 September, 18:14
Thank you!
Syed Tayyab ul MazharLevel 11 , Karachi
14 June, 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 20 , Painesville
26 May, 23:19
That's what I did.
Oleg VanyushkinLevel 18 , St.-Petersburg
9 April, 08:29
Just catched everything.
Philip ObiorahLevel 10 , Port - Harcourt
8 April, 12:56
sweet
Ivaylo TrifonovLevel 18 , Madrid
27 March, 09:55
Tip: Read the tip at the end before starting to work on the tasks : )