1. | Which of the following statements are correct about data types? 1. If the integer literal exceeds the range of byte, a compilation error will occur. 2. We cannot implicitly convert non-literal numeric types of larger storage size to byte. 3. Byte cannot be implicitly converted to float. 4. A char can be implicitly converted to only int data type. 5. We can cast the integral character codes. |
A. | 1,3,5 |
B. | 2,4 |
C. | 3,5 |
D. | 1,2,5 |
Answer» D. 1,2,5 |
2. | Which of the following is NOT an Integer? |
A. | Char |
B. | Byte |
C. | Integer |
D. | Long |
Answer» A. Char |
3. | What will be the output of the following code snippet when it is executed? int x = 1; float y = 1.1f; short z = 1; Console.Write.Line((float) x + y * z – (x += (short) y)); |
A. | 0.1 |
B. | 1.0 |
C. | 1.1 |
D. | 11 |
Answer» A. 0.1 |
4. | Which of the following is the correct size of a Decimal datatype? |
A. | 8 bytes |
B. | 4 bytes |
C. | 10 bytes |
D. | None of the above |
Answer» D. None of the above |
5. | Which of the following statements are correct? 1. We can assign values of any type to variables of type object. 2. When a variable of a value type is converted to object, it is said to be unboxed. 3. When a variable of type object is converted to a value type, it is said to be boxed. 4. Boolean variable cannot have a value of null. 5. When a value type is boxed, an entirely new object must be allocated and constructed. |
A. | 2,5 |
B. | 1,5 |
C. | 3,4 |
D. | 2,3 |
Answer» B. 1,5 |
6. | Which of the following is the correct ways to set a value 3.14 in a variable pi such that it cannot be modified? |
A. | float pi = 3.14F; |
B. | #define pi 3.14F; |
C. | const float pi = 3.14F; |
D. | const float pi; pi = 3.14F; |
Answer» C. const float pi = 3.14F; |
7. | Which of the following can be used to terminate a while loop and transfer control outside the loop? 1. exit while 2. continue 3. exit statement 4. break 5. goto |
A. | 1,3 |
B. | 2,4 |
C. | 3,5 |
D. | 4,5 |
Answer» D. 4,5 |
8. | Which of the following statements are correct about the C#.NET code snippet given below? if (age > 18 && no < 11) a = 25; 1. The condition no < 11 will be evaluated only if age > 18 evaluates to True. 2. The statement a = 25 will get executed if any one condition is True. 3. The condition no < 11 will be evaluated only if age > 18 evaluates to False. 4. The statement a = 25 will get executed if both the conditions are True. 5. && is known as a short circuiting logical operator. |
A. | 1,3 |
B. | 2,5 |
C. | 1,4,5, |
D. | 3,4,5 |
Answer» C. 1,4,5, |
9. | Which of the following is the correct output for the C#.NET code snippet given below? Console.WriteLine(13 / 2 + ” ” + 13 % 2); |
A. | 6.5 1 |
B. | 6.5 0 |
C. | 6 0 |
D. | 6 1 |
Answer» D. 6 1 |
10. | Which of the following statements are correct? 1. Instance members of a class can be accessed only through an object of that class. 2. A class can contain only instance data and instance member function. 3. All objects created from a class will occupy equal number of bytes in memory. 4. A class can contain Friend functions. 5. A class is a blueprint or a template according to which objects are created. |
A. | 1,3,5 |
B. | 2,4 |
C. | 3,5 |
D. | 2,4,5 |
Answer» A. 1,3,5 |
11. | Which of the following is the correct way to create an object of the class Sample? 1. Sample s = new Sample(); 2. Sample s; 3. Sample s; s = new Sample(); 4. s = new Sample(); |
A. | 1,3 |
B. | 2,4 |
C. | 1,2,3 |
D. | 4,5 |
Answer» A. 1,3 |
12. | Which of the following statements is correct about constructors? |
A. | If we provide a one-argument constructor then the compiler still provides a zeroargument constructor. |
B. | Overloaded constructors have the same name as the class name |
C. | Overloaded constructors cannot use optional arguments. |
D. | If we do not provide a constructor, then the compiler provides a zero-argument constructor. |
Answer» D. If we do not provide a constructor, then the compiler provides a zero-argument constructor. |
13. | Which of the following statements is correct? |
A. | There is one garbage collector per program running in memory. |
B. | There is one common garbage collector for all programs. |
C. | An object is destroyed by the garbage collector when only one reference refers to it. |
D. | We have to specifically run the garbage collector after executing Visual Studio.NET. |
Answer» B. There is one common garbage collector for all programs. |
14. | Which of the following can be facilitated by the Inheritance mechanism? 1. Use the existing functionality of base class. 2. Overrride the existing functionality of base class. 3. Implement new functionality in the derived class. 4. Implement polymorphic behaviour. 5. Implement containership. |
A. | 1,2,3 |
B. | 3,4 |
C. | 2,4,5 |
D. | 3,5 |
Answer» A. 1,2,3 |
15. | Which one of the following statements is correct? |
A. | Array elements can be of integer type only. |
B. | The rank of an Array is the total number of elements it can contain. |
C. | The length of an Array is the number of dimensions in the Array. |
D. | The default value of numeric array elements is zero. |
Answer» D. The default value of numeric array elements is zero. |
16. | Which of the following statements are correct about arrays used in C#.NET? 1. Arrays can be rectangular or jagged. 2. Rectangular arrays have similar rows stored in adjacent memory locations. 3. Jagged arrays do not have an access to the methods of System.Array Class. 4. Rectangular arrays do not have an access to the methods of System.Array Class. 5. Jagged arrays have dissimilar rows stored in non-adjacent memory locations. |
A. | 1,2 |
B. | 1,3,5 |
C. | 3,4 |
D. | 1,2,5 |
Answer» D. 1,2,5 |
17. | Which of the following statements are correct? 1. A struct can contain properties. 2. A struct can contain constructors. 3. A struct can contain protected data members. 4. A struct cannot contain methods. 5. A struct cannot contain constants. |
A. | 1,2 |
B. | 3,4 |
C. | 1,2,4 |
D. | 3,5 |
Answer» A. 1,2 |
18. | Which of the following will be the correct output for the C#.NET code snippet given below? String s1 = “ALL MEN ARE CREATED EQUAL”; String s2; s2 = s1.Substring(12, 3); Console.WriteLine(s2); |
A. | ARE |
B. | CRE |
C. | CR |
D. | REA |
Answer» B. CRE |
19. | If s1 and s2 are references to two strings, then which of the following is the correct way to compare the two references? |
A. | s1 is s2 |
B. | s1=s2 |
C. | s1==s2 |
D. | s1.Equals(s2) |
Answer» D. s1.Equals(s2) |
20. | Which of the following statements is correct about an Exception? |
A. | It occurs during compilation. |
B. | It occurs during linking. |
C. | It occurs at run-time. |
D. | It occurs during Just-In-Time compilation. |
Answer» C. It occurs at run-time. |
21. | Which of the following statements are correct about exception handling in C#.NET? 1 If an exception occurs then the program terminates abruptly without getting any chance to recover from the exception. 2 No matter whether an exception occurs or not, the statements in the finally clause (if present) will get executed. 3 A program can contain multiple finally clauses. 4 A finally clause is written outside the try block. 5 Finally clause is used to perform cleanup operations like closing the network/database connections. |
A. | 1 only |
B. | 2 only |
C. | 2 and 5 only |
D. | 3 and 4 only |
Answer» C. 2 and 5 only |
22. | ______ parameters are used to pass results back to the calling method. |
A. | Input |
B. | Reference |
C. | Value |
D. | Output |
Answer» D. Output |
23. | The formal-parameter-list is always enclosed in _______. |
A. | Square |
B. | Semicolon |
C. | Parenthesis |
D. | Colon |
Answer» C. Parenthesis |
24. | _______ variables are visible only in the block they are declared. |
A. | System |
B. | Global |
C. | Local |
D. | Console |
Answer» C. Local |
26. | A structure in C# provides a unique way of packing together data of ______ types. |
A. | Different |
B. | Same |
C. | Invoking |
D. | Calling |
Answer» A. Different |
27. | Struct’s data members are ____________ by default. |
A. | Protected |
B. | Public |
C. | Private |
D. | Default |
Answer» C. Private |
28. | A _______ creates an object by copying variables from another object. |
A. | Copy constructor |
B. | Default constructor |
C. | Invoking constructor |
D. | Calling constructor |
Answer» A. Copy constructor |
29. | The methods that have the same name, but different parameter lists and different definitions is called______. |
A. | Method Overloading |
B. | Method Overriding |
C. | Method Overwriting |
D. | Method Overreading |
Answer» A. Method Overloading |
30. | The C# provides special methods known as _____ methods to provide access to data members. |
A. | Loop |
B. | Functions |
C. | Methods |
D. | Accessor |
Answer» D. Accessor |
31. | Storage location used by computer memory to store data for usage by an application is ? |
A. | Pointers |
B. | Constants |
C. | Variable |
D. | None of the mentioned |
Answer» C. Variable |
32. | Which of these can be overloaded? |
A. | Constructors |
B. | Methods |
C. | Both a & b |
D. | None of the mentioned |
Answer» C. Both a & b |
33. | Number of constructors a class can define of ? |
A. | 1 |
B. | 2 |
C. | Any number |
D. | None of the mentioned |
Answer» C. Any number |
34. | Correct statement about constructors in C#.NET is ? |
A. | Constructor cannot be overloaded |
B. | Constructor allocate space for object in memory |
C. | Constructor are never called explicitly |
D. | Constructor have same name as name of the class |
Answer» D. Constructor have same name as name of the class |
35. | Constructors are used to |
A. | initialize the objects |
B. | construct the data members |
C. | both a & b |
D. | None of the mentioned |
Answer» C. both a & b |
36. | To overload a method which of the following statement is false? |
A. | If the return type is different methods are overloaded |
B. | Name of the overloaded method should be same |
C. | Type of the parameter should be different |
D. | Order of the parameter should be different if types are same |
Answer» A. If the return type is different methods are overloaded |
37. | Which of the following statements is correct about constructors in C#.NET? |
A. | A constructor cannot be declared as private |
B. | A constructor cannot be overloaded |
C. | A constructor can be a static constructor |
D. | None of the mentioned |
Answer» D. None of the mentioned |
38. | What is return type of constructors? |
A. | int |
B. | float |
C. | void |
D. | None of the mentioned |
Answer» D. None of the mentioned |
39. | Which method have same name as that of its class? |
A. | delete |
B. | class |
C. | constructor |
D. | None of mentioned |
Answer» C. constructor |
40. | Which of following statement are correct about functions? |
A. | C# allows a function to have arguments with default values |
B. | Redefining a method parameter in the method’s body causes an exception |
C. | C# allows function to have arguments of private type |
D. | Omitting the return type in method definition results into exception |
Answer» A. C# allows a function to have arguments with default values |
Tags
Question and answers in Unit 2,Unit 2 Multiple choice questions and answers,Unit 2 Important MCQs,Solved MCQs for Unit 2,Unit 2 MCQs with answers PDF download