C# Set 4 (29 mcqs)

1. Which exception is being thrown if the URI format is invalid?
a) URLNotFound
b) URLSourceNotFound
c) MalformedURLException
d) UriFormatException

2. Which exception is being thrown if the protocol supported by URI prefix is invalid?
a) URLNotFound
b) URLSourceNotFound
c) UriFormatException
d) NotSupportedException

3. Which exception is being thrown if the user does not have proper authorization?
a) URLNotFound
b) URLSourceNotFound
c) System.Security.SecurityException
d) All of the mentioned

4. Choose the exceptions generated by the Create() method defined by WebRequest:
a) NotSupportedException
b) UriFormatException
c) System.Security.SecurityException
d) ArgumentNullException

5. Choose the exceptions generated by the GetReponse() method defined by WebRequest:
a) InvalidOperationException
b) ProtocolViolationException
c) WebException
d) UriFormatException

6. Select the two properties related to the network errors generated by WebException:
a) Response
b) get
c) Status
d) set

7. Which of these class is used for operating on request from the client to the server?
a) http
b) httpDecoder
c) httpConnection
d) httpd

8. Choose the exceptions generated by the GetResponseStream() method defined by WebRequest:
a) ProtocolViolationException
b) ObjectDisposedException
c) UriFormatException
d) IOException

9. Which of these class is used to create servers that listen for either local or remote client programs?
a) httpServer
b) ServerSockets
c) MimeHeader
d) HttpResponse

10. Which of these methods is used to know the full URL of an URL object?
a) fullHost()
b) getHost()
c) AbsoluteUri
d) toExternalForm()

11. Select which among is NOT an exception?
a) Stack Overflow
b) Arithmetic Overflow or underflow
c) Incorrect Arithmetic Expression
d) All of the above mentioned

12. Select which among is NOT considered as .NET Exception class?
a) Exception
b) StackUnderflow Exception
c) File Found Exception
d) Divide By zero Exception

13. Which is the object oriented way to handle run time errors?
a) Error codes
b) HERRESULT
c) OnError
d) Exceptions

14. Select the statements which describes correctly usage of exception handling over conventional error handling approaches?
a) As errors can be ignored but exceptions cannot be ignored
b) Exception handling allows seperation of program’s logic from error handling logic making software more reliable and maintainable
c) try – catch – finally structure allows guaranteed cleanup in event of errors under all circumstances
d) All of the above mentioned

15. Select the correct statement about an Exception?
a) It occurs during loading of program
b) It occurs during Just-In-Time compilation
c) It occurs at run time
d) All of the above mentioned

16. Which of these keywords is not a part of exception handling?
a) try
b) finally
c) thrown
d) catch
.
17. Which of these keywords must be used to monitor for exceptions?
a) try
b) finally
c) throw
d) catch

18. Which of these keywords is used to manually throw an exception?
a) try
b) finally
c) throw
d) catch
.
19. Choose the correct output for given set of code:
1.class program
2.{
3.    static void main(string[] args)
4.    {
5.        int i = 5;
6.        int v = 40;
7.        int[] p = new int[4];
8.        try
9.        {
10.            p[i] = v;
11.        }
12.        catch(IndexOutOfRangeException e)
13.        {
14.            Console.WriteLine(“Index out of bounds”);
15.        }
16.        Console.WriteLine(“Remaining program”);
17.    }
18.}
a) value 40 will be assigned to a[5];
b) The output will be :
Index out of bounds
Remaining program
c) The output will be :
Remaining program
d) None of the above mentioned

20. Choose the correct output for given set of code:
1.static void Main(string[] args)
2.{
3.    try
4.    {
5.        Console.WriteLine(“csharp” + ” ” + 1/Convert.ToInt32(0));
6.    }
7.    catch(ArithmeticException e)
8.    {
9.        Console.WriteLine(“Java”);
10.    }
11.    Console.ReadLine();
12.}
a) csharp
b) java
c) Run time error
d) csharp 0

21. Which statement correctly defines about Interfaces in C#.NET?
a) Interfaces cannot be inherited
b) Interfaces consists of data static in nature and static methods
c) Interfaces consists of only method declaration
d) None of the mentioned

22. Which of the following can be used to declare an interface correctly?
a) Properties
b) Methods
c) Structures
d) Events

23. A class consists of two interfaces with each interface consisting of three methods.The class had no instance data which indicates correct size of object created from this class?
a) 12 bytes
b) 16 bytes
c) 0 bytes
d) 24 bytes

24. Statement correctly defines about the implementation of interface?
a) The calls to implementations of interface method are routed through a method table
b) A class which implements an interface can explicitly implement members of that interface
c) One interface can be implemented in another interface
d) None of the mentioned

25. Select the correct statement among the given statements?
a) One class could implement only one interface
b) Properties could be declared inside an interface
c) Interfaces cannot be inherited
d) None of the above mentioned

26. Which keyword used for correct implementation of an interface in C#.NET?
a) interface
b) Interface
c) intf
d) Intf

27. Choose statements which makes interface different from classes?
a) Unlike classes, interfaces consists of only declaration but not implementation
b) Interfaces cannot be used directly like classes to create new objects
c) Interfaces consists of declaration of methods,properties events and type definitions
d) None of the mentioned

28. Which of the following is correct way of implementing an interface addition by class maths?
a) class maths : addition {}
b) class maths implements addition {}
c) class maths imports addition {}
d) None of the mentioned

29. Does C#.NET supports partial implementation of interfaces?
a) True
b) False
c) Can’t Say
d) None of the above mentioned

Answers

1-d 2-d 3-c 4-a,b,c,d 5-a,b,c
6- a,c 7- d 8- a,b,d 9- a 10- c
11-c 12-b,c 13-d 14-d 15-c
16-c 17-a 18-c 19-b 20-b
21-d 22-a,b,d 23-d 24-a,b 25-b
26-a 27- a,b,c 28-a 29- b

Sharing is caring!

Leave a Comment

Your email address will not be published. Required fields are marked *

shares