CJCoding With Joseph
TitleTopicsAction
643
Catch Divide By ZeroRead two integers `a` and `b` (each on its own line) and print `a / b`. If `b` i...
easy○ Not Started
Exceptions
Solve
644
Parse Integer SafelyRead one line of input and parse it to an integer with `int.Parse`. If it succee...
easy○ Not Started
Exceptions
Solve
645
The finally BlockRead two integers and print `Result: <a / b>`. Catch a `DivideByZeroException` a...
easy○ Not Started
Exceptions
Solve
646
Array Index Out Of RangeAn array `arr = { 10, 20, 30 }` is given. Read an index from input and print `ar...
easy○ Not Started
Exceptions
Solve
647
Throw ArgumentException On Empty NameRead a name from input. If it is empty, `throw new ArgumentException("empty")`; ...
easy○ Not Started
Exceptions
Solve
648
Print The Exception MessageRead an age. If it is negative, `throw new Exception("age cannot be negative")`;...
easy○ Not Started
Exceptions
Solve
656
List Index Out Of RangeA `List<int>` holds `{ 5, 10, 15 }`. Read an index and print `list[index]`. Unli...
easy○ Not Started
Exceptions
Solve
658
Invalid Operation ExceptionRead a `count`. If it is `0`, `throw new InvalidOperationException("stack is emp...
easy○ Not Started
Exceptions
Solve
659
Throw And Catch A General ExceptionRead an integer `n`. If `n > 100`, `throw new Exception("too big")`; otherwise p...
easy○ Not Started
Exceptions
Solve
660
finally Always RunsPrint `Try`, then throw an exception. Catch it and print `Catch`. Finally, print...
easy○ Not Started
Exceptions
Solve
663
Null Reference ExceptionA variable `text` starts as `null`. Read an integer `cmd`; if `cmd == 1`, set `t...
easy○ Not Started
Exceptions
Solve
667
Fallback Value On Parse ErrorDeclare `int n;`. Read a line and try to parse it into `n`. If parsing throws a ...
easy○ Not Started
Exceptions
Solve
668
Catch a Divide By ZeroRead two integers `a` and `b` (one per line), then print the result of `a / b`. ...
easy○ Not Started
Exceptions
Solve
669
Handle Invalid Number FormatRead one line of input and parse it to an `int` with `int.Parse`, then print `Nu...
easy○ Not Started
Exceptions
Solve
670
Read the Exception MessageThe `try` block throws `new InvalidOperationException("operation not allowed")`....
easy○ Not Started
Exceptions
Solve
671
Catch Any ExceptionRead an integer `n` and print `100 / n`. Instead of catching a specific type, ca...
easy○ Not Started
Exceptions
Solve
672
The finally Block Always RunsRead an integer and print `Parsed: <n>`. If the input is not a number, catch the...
easy○ Not Started
Exceptions
Solve
673
Throw an ArgumentExceptionRead an age. If it is negative, `throw new ArgumentException("age cannot be nega...
easy○ Not Started
Exceptions
Solve
674
Null Reference HandlingThe variable `text` is set to `null`. Reading `text.Length` on a null reference ...
easy○ Not Started
Exceptions
Solve
675
Catch the Base ArithmeticExceptionRead two integers and print `a / b`. `DivideByZeroException` derives from `Arith...
easy○ Not Started
Exceptions
Solve
676
Print the Exception Type NameRead an integer and print `Value: <n>`. If parsing fails, catch the exception an...
easy○ Not Started
Exceptions
Solve
677
Convert.ToInt32 Can Throw TooRead a line and convert it with `Convert.ToInt32`, then print `Doubled: <n*2>`. ...
easy○ Not Started
Exceptions
Solve
678
Recover With a Default ValueTry to parse the input into a variable named `value`. If parsing throws a `Forma...
easy○ Not Started
Exceptions
Solve
679
Substring Out Of RangeRead a string and print its first three characters using `s.Substring(0, 3)`. If...
easy○ Not Started
Exceptions
Solve
649
Multiple Catch BlocksRead two integers and print their quotient. Use two separate catch blocks: a `Fo...
medium○ Not Started
Exceptions
Solve
650
Custom Exception ClassDefine a custom exception `InsufficientFundsException` that inherits from `Excep...
medium○ Not Started
Exceptions
Solve
652
Exception Filter With whenRead an integer status code. If it is `>= 400`, `throw new Exception(code.ToStri...
medium○ Not Started
Exceptions
Solve
653
Checked OverflowRead two integers and add them inside a `checked(...)` expression, then print `S...
medium○ Not Started
Exceptions
Solve
654
ArgumentNullExceptionRead one line. Treat the literal text `null` as a null string. If the value is n...
medium○ Not Started
Exceptions
Solve
655
Key Not Found In DictionaryA dictionary maps `Alice -> 30` and `Bob -> 25`. Read a name (a key) and print i...
medium○ Not Started
Exceptions
Solve
661
Validate Percentage RangeRead an integer `percent`. If it is `< 0` or `> 100`, explicitly `throw new Argu...
medium○ Not Started
Exceptions
Solve
662
Overflow On Byte CastRead an integer `n` and convert it to a `byte` using `checked((byte)n)`, then pr...
medium○ Not Started
Exceptions
Solve
665
Identify The Exception TypeRead an integer `n`. If `n == 0`, throw a `DivideByZeroException`; if `n < 0`, t...
medium○ Not Started
Exceptions
Solve
680
Two Catch BlocksRead two integers and print `a / b`. Handle two different failures with two catc...
medium○ Not Started
Exceptions
Solve
681
Overflow When Parsing a ByteRead a line and parse it into a `byte` (which holds `0` to `255`) using `byte.Pa...
medium○ Not Started
Exceptions
Solve
682
Invalid Operation on an Empty ListRead an integer `n`. Create an empty `List<int>` and add `n` only if `n > 0`. Th...
medium○ Not Started
Exceptions
Solve
683
Missing Dictionary KeyA `Dictionary<string, int>` maps names to ages (`Alice`=30, `Bob`=25). Read a na...
medium○ Not Started
Exceptions
Solve
684
Filter With a when ClauseRead an integer `code`, then `throw new InvalidOperationException(code.ToString(...
medium○ Not Started
Exceptions
Solve
685
Nested Try/CatchRead an integer `n`. Inside an inner `try`, print `10 / n`; its catch handles `D...
medium○ Not Started
Exceptions
Solve
686
Argument Cannot Be NullRead an `id`. If `id` is `1` the name is `Alice`, otherwise the name is `null`. ...
medium○ Not Started
Exceptions
Solve
687
Validate a RangeRead a `score`. Valid scores are `0` to `100` inclusive. If the score is outside...
medium○ Not Started
Exceptions
Solve
688
Throw From a MethodRead an integer `n` and print `Result: <100 / n>` using a helper method `DivideH...
medium○ Not Started
Exceptions
Solve
700
Catch An Invalid CastAn `object` variable can hold any type, but unboxing it to the wrong type throws...
medium○ Not Started
Exceptions
Solve
651
Rethrow With Nested TryRead an integer `n`. Use a nested `try`/`catch`. In the inner try: if `n == 0`, ...
hard○ Not Started
Exceptions
Solve
657
Custom Exception With DataDefine a custom exception `NegativeNumberException` that stores the rejected num...
hard○ Not Started
Exceptions
Solve
664
Wrap With Inner ExceptionUse a nested `try`/`catch`. Inner try: read `n`; if `n < 0`, `throw new Argument...
hard○ Not Started
Exceptions
Solve
666
Function That ThrowsRead two integers and print `Result: <Divide(a, b)>`. Write a local function `in...
hard○ Not Started
Exceptions
Solve
689
Define a Custom ExceptionDefine your own exception class `NegativeNumberException` that extends `Exceptio...
hard○ Not Started
Exceptions
Solve
690
Rethrow With throw;Read an integer `n`. In an inner `try`, throw a `DivideByZeroException` when `n ...
hard○ Not Started
Exceptions
Solve
691
Custom Exception With Data and finallyDefine an `InsufficientFundsException` with an `int Shortfall` property set thro...
hard○ Not Started
Exceptions
Solve