CJCoding With Joseph
15free / daySign inCreate account
TitleTopicsAction
733
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
734
Parse Integer SafelyRead one line of input and parse it to an integer with `int.Parse`. If it succee...
easy○ Not Started
Exceptions
Solve
735
The finally BlockRead two integers and print `Result: <a / b>`. Catch a `DivideByZeroException` a...
easy○ Not Started
Exceptions
Solve
736
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
737
Throw ArgumentException On Empty NameRead a name from input. If it is empty, `throw new ArgumentException("empty")`; ...
easy○ Not Started
Exceptions
Solve
738
Print The Exception MessageRead an age. If it is negative, `throw new Exception("age cannot be negative")`;...
easy○ Not Started
Exceptions
Solve
746
List Index Out Of RangeA `List<int>` holds `{ 5, 10, 15 }`. Read an index and print `list[index]`. Unli...
easy○ Not Started
Exceptions
Solve
748
Invalid Operation ExceptionRead a `count`. If it is `0`, `throw new InvalidOperationException("stack is emp...
easy○ Not Started
Exceptions
Solve
749
Throw And Catch A General ExceptionRead an integer `n`. If `n > 100`, `throw new Exception("too big")`; otherwise p...
easy○ Not Started
Exceptions
Solve
750
finally Always RunsPrint `Try`, then throw an exception. Catch it and print `Catch`. Finally, print...
easy○ Not Started
Exceptions
Solve
753
Null Reference ExceptionA variable `text` starts as `null`. Read an integer `cmd`; if `cmd == 1`, set `t...
easy○ Not Started
Exceptions
Solve
757
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
758
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
759
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
760
Read the Exception MessageThe `try` block throws `new InvalidOperationException("operation not allowed")`....
easy○ Not Started
Exceptions
Solve
761
Catch Any ExceptionRead an integer `n` and print `100 / n`. Instead of catching a specific type, ca...
easy○ Not Started
Exceptions
Solve
762
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
763
Throw an ArgumentExceptionRead an age. If it is negative, `throw new ArgumentException("age cannot be nega...
easy○ Not Started
Exceptions
Solve
764
Null Reference HandlingThe variable `text` is set to `null`. Reading `text.Length` on a null reference ...
easy○ Not Started
Exceptions
Solve
765
Catch the Base ArithmeticExceptionRead two integers and print `a / b`. `DivideByZeroException` derives from `Arith...
easy○ Not Started
Exceptions
Solve
766
Print the Exception Type NameRead an integer and print `Value: <n>`. If parsing fails, catch the exception an...
easy○ Not Started
Exceptions
Solve
767
Convert.ToInt32 Can Throw TooRead a line and convert it with `Convert.ToInt32`, then print `Doubled: <n*2>`. ...
easy○ Not Started
Exceptions
Solve
768
Recover With a Default ValueTry to parse the input into a variable named `value`. If parsing throws a `Forma...
easy○ Not Started
Exceptions
Solve
769
Substring Out Of RangeRead a string and print its first three characters using `s.Substring(0, 3)`. If...
easy○ Not Started
Exceptions
Solve
739
Multiple Catch BlocksRead two integers and print their quotient. Use two separate catch blocks: a `Fo...
medium○ Not Started
Exceptions
Solve
740
Custom Exception ClassDefine a custom exception `InsufficientFundsException` that inherits from `Excep...
medium○ Not Started
Exceptions
Solve
742
Exception Filter With whenRead an integer status code. If it is `>= 400`, `throw new Exception(code.ToStri...
medium○ Not Started
Exceptions
Solve
743
Checked OverflowRead two integers and add them inside a `checked(...)` expression, then print `S...
medium○ Not Started
Exceptions
Solve
744
ArgumentNullExceptionRead one line. Treat the literal text `null` as a null string. If the value is n...
medium○ Not Started
Exceptions
Solve
745
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
751
Validate Percentage RangeRead an integer `percent`. If it is `< 0` or `> 100`, explicitly `throw new Argu...
medium○ Not Started
Exceptions
Solve
752
Overflow On Byte CastRead an integer `n` and convert it to a `byte` using `checked((byte)n)`, then pr...
medium○ Not Started
Exceptions
Solve
755
Identify The Exception TypeRead an integer `n`. If `n == 0`, throw a `DivideByZeroException`; if `n < 0`, t...
medium○ Not Started
Exceptions
Solve
770
Two Catch BlocksRead two integers and print `a / b`. Handle two different failures with two catc...
medium○ Not Started
Exceptions
Solve
771
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
772
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
773
Missing Dictionary KeyA `Dictionary<string, int>` maps names to ages (`Alice`=30, `Bob`=25). Read a na...
medium○ Not Started
Exceptions
Solve
774
Filter With a when ClauseRead an integer `code`, then `throw new InvalidOperationException(code.ToString(...
medium○ Not Started
Exceptions
Solve
775
Nested Try/CatchRead an integer `n`. Inside an inner `try`, print `10 / n`; its catch handles `D...
medium○ Not Started
Exceptions
Solve
776
Argument Cannot Be NullRead an `id`. If `id` is `1` the name is `Alice`, otherwise the name is `null`. ...
medium○ Not Started
Exceptions
Solve
777
Validate a RangeRead a `score`. Valid scores are `0` to `100` inclusive. If the score is outside...
medium○ Not Started
Exceptions
Solve
778
Throw From a MethodRead an integer `n` and print `Result: <100 / n>` using a helper method `DivideH...
medium○ Not Started
Exceptions
Solve
790
Catch An Invalid CastAn `object` variable can hold any type, but unboxing it to the wrong type throws...
medium○ Not Started
Exceptions
Solve
741
Rethrow With Nested TryRead an integer `n`. Use a nested `try`/`catch`. In the inner try: if `n == 0`, ...
hard○ Not Started
Exceptions
Solve
747
Custom Exception With DataDefine a custom exception `NegativeNumberException` that stores the rejected num...
hard○ Not Started
Exceptions
Solve
754
Wrap With Inner ExceptionUse a nested `try`/`catch`. Inner try: read `n`; if `n < 0`, `throw new Argument...
hard○ Not Started
Exceptions
Solve
756
Function That ThrowsRead two integers and print `Result: <Divide(a, b)>`. Write a local function `in...
hard○ Not Started
Exceptions
Solve
779
Define a Custom ExceptionDefine your own exception class `NegativeNumberException` that extends `Exceptio...
hard○ Not Started
Exceptions
Solve
780
Rethrow With throw;Read an integer `n`. In an inner `try`, throw a `DivideByZeroException` when `n ...
hard○ Not Started
Exceptions
Solve
781
Custom Exception With Data and finallyDefine an `InsufficientFundsException` with an `int Shortfall` property set thro...
hard○ Not Started
Exceptions
Solve