C#.NET objective type questions and answers

1. Which of the following statements is correct about properties used in C#.NET?
a. A property can simultaneously be read only or write only. (False!)
b. A property can be either read only or write only. (True)
c. A write only property will have only get accessor. (False!)
d. A write only property will always return a value. (False!)
Correct answers: b
Not answered
2. A Student class has a property called rollNo and stu is a reference to a Student object and we want the statement stu.RollNo = 28 to fail. Which of the following options will ensure this functionality?
a. Declare rollNo property with both get and set accessors. (False!)
b. Declare rollNo property with only set accessor. (False!)
c. Declare rollNo property with get, set and normal accessors. (False!)
d. Declare rollNo property with only get accessor. (True)
Correct answers: d
Not answered
3. Which of the following statements are correct?
a. The signature of an indexer consists of the number and types of its formal parameters. (True)
b. Indexers are similar to properties except that their accessors take parameters. (True)
c. Accessors of interface indexers use modifiers. (False!)
d. The type of an indexer and the type of its parameters must be at least as accessible as the indexer itself. (True)
e. An interface accessor contains a body. (False!)
Correct answers: a, b, d
Not answered
4. Which of the following statements is correct about properties used in C#.NET?
a. Every property must have a set accessor and a get accessor. (False!)
b. Properties cannot be overloaded. (False!)
c. Properties of a class are actually methods that work like data members. (True)
d. A property has to be either read only or a write only. (False!)
Correct answers: c
Not answered
5. Which of the folowing does an indexer allow to index in the same way as an array?
a. A class (True)
b. A property (False!)
c. A struct (False!)
d. A function (False!)
e. An interface (False!)
Correct answers: a
Not answered
6. An Employee class has a property called age and emp is reference to a Employee object and we want the statement Console.WriteLine(emp.age) to fail. Which of the following options will ensure this functionality?
Console.WriteLine(13 / 2 + " " + 13 % 2);
a. Declare age property with only get accessor (False!)
b. Declare age property with only set accessor. (True)
c. Declare age property with both get and set accessors. (False!)
d. Declare age property with get, set and normal accessors. (False!)
Correct answers: b
Not answered
7. Which of the following statements are correct about data types?
a. If the integer literal exceeds the range of byte, a compilation error will occur. (True)
b. We cannot implicitly convert non-literal numeric types of larger storage size to byte. (True)
c. Byte cannot be implicitly converted to float. (False!)
d. A char can be implicitly converted to only int data type. (False!)
e. We can cast the integral character codes. (True)
Correct answers: a, b, e
Not answered
8. Which of the following is an 8-byte Integer?
a. Char (False!)
b. Long (True)
c. Short (False!)
d. Byte (False!)
e. Integer (False!)
Correct answers: b
Not answered
9. Which of the following is NOT an Integer?
a. Char (True)
b. Byte (False!)
c. Integer (False!)
d. Short (False!)
e. Long (False!)
Correct answers: a
Not answered
10. Which of the following statements is correct?
a. Information is never lost during narrowing conversions. (False!)
b. The CInteger() function can be used to convert a Single to an Integer. (False!)
c. Widening conversions take place automatically. (True)
d. Assigning an Integer to an Object type is known as Unboxing. (False!)
e. 3.14 can be treated as Decimal by using it in the form 3.14F (False!)
Correct answers: c
Not answered
11. Which of the following are value types?
a. Integer (True)
b. Array (False!)
c. Single (True)
d. String (False!)
e. Long (True)
Correct answers: a, c, e
Not answered
12. Which of the following does not store a sign?
a. Short (False!)
b. Integer (False!)
c. Long (False!)
d. Byte (True)
e. Short (False!)
Correct answers: d
Not answered
13. What is the size of a Decimal?
a. 4 byte (False!)
b. 8 byte (False!)
c. 16 byte (True)
d. 32 byte (False!)
e. 64 byte (False!)
Correct answers: c
Not answered
14. Which of the following is the correct size of a Decimal datatype?
a. 8 Bytes (False!)
b. 4 Bytes (False!)
c. 10 Bytes (False!)
d. 16 Bytes (True)
Correct answers: d
Not answered
15. Which of the following statements are correct?
a. We can assign values of any type to variables of type object. (True)
b. When a variable of a value type is converted to object, it is said to be unboxed. (False!)
c. When a variable of type object is converted to a value type, it is said to be boxed. (False!)
d. Boolean variable cannot have a value of null. (False!)
e. When a value type is boxed, an entirely new object must be allocated and constructed. (True)
Correct answers: a, e
Not answered
16. 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; (False!)
b. #define pi 3.14F; (False!)
c. const float pi = 3.14F; (True)
d. const float pi; pi = 3.14F; (False!)
e. pi = 3.14F; (False!)
Correct answers: c
Not answered
17. Which of the following statements are correct about data types?
a. Each value type has an implicit default constructor that initializes the default value of that type. (True)
b. It is possible for a value type to contain the null value. (False!)
c. All value types are derived implicitly from System.ValueType class. (True)
d. It is not essential that local variables in C# must be initialized before being used. (False!)
e. Variables of reference types referred to as objects and store references to the actual data. (True)
Correct answers: a, c, e
Not answered
18. Which of the following statement correctly assigns a value 33 to a variable c?
byte a = 11, b = 22, c;
a. c = (byte) (a + b); (True)
b. c = (byte) a + (byte) b; (False!)
c. c = (int) a + (int) b; (False!)
d. c = (int)(a + b); (False!)
e. c = a + b; (False!)
Correct answers: a
Not answered
19. Which of the following statements are correct about datatypes in C#.NET?
a. Every datatype is either a value type or a reference type. (True)
b. Value types are always created on the heap. (False!)
c. Reference types are always created on the stack. (False!)
d. Mapping of every value type to a type in Common Type System facilitates Interoperability in C#.NET. (True)
e. Every reference type gets mapped to a type in Common Type System. (False!)
Correct answers: a, d
Not answered
20. Which of the following is the correct default value of a Boolean type?
a. 0 (False!)
b. 1 (False!)
c. True (False!)
d. False (True)
e. -1 (False!)
Correct answers: d
Not answered
   

Today's date:
Total spent time:
Total answered question:
Total unanswered question:





Post a Comment

0 Comments