C#(Sharp) MCQ
Soopro Pathshala provides C#(sharp) MCQ(Multiple Choice Questions)
1. How many Bytes are stored by ‘Long’ Data type in C# .net?
a) 8
b) 4
c) 2
d) 1
View Answer
2. What is the extension of a C# language file?
a) .c
b) .cpp
c) .cs
d) .csp
View Answer
3. Who is the founder of C# programming language?
a) Anders Hejlsberg
b) Douglas Crockford
c) Rasmus Lerdorf
d) Brendan Eich
View Answer
Answer: (a) Anders Hejlsberg
4. In C#, a single-line comment starts with ___.
a) Two forward slashes (//)
b) Two backward slashes (\\)
c) A hash character (#)
d) A dollar character ($)
View Answer
Answer: (a) Two forward slashes (//)
5. Which data type is used to store text value in C#?
a) text
b) txt
c) string
d) str
View Answer
6. Which of the following converts a type to a floating point number in C#?
a) ToInt64
b) ToSbyte
c) ToSingle
d) ToInt32
View Answer
7. Which of the following is the default access specifier of a class?
a) Private
b) Public
c) Protected
d) Internal
View Answer
8. The execution of the program begins with _______.
a) Main()
b) get()
c) class()
d) display()
View Answer
9. WriteLine is a __________.
a) function
b) keyword
c) literal
d) class
View Answer
10. "new" is used for ________ the objects.
a) creating
b) modifying
c) allocating memory for.
d) deallocating memory of
View Answer
Answer: (c) allocating memory for
11. A number divided by zero is __________ Exception
a) ArgumentNull
b) InvalidCast
c) OverFlow
d) Arithmetic
View Answer
12. Any real word entity is called __________.
a) object
b) attribute
c) characteristic
d) class
View Answer
13. Which C# keyword is used to define a constant?
a) define
b) fixed
c) constant
d) const
View Answer
14. Which is not a valid C# data type?
a) long
b) int
c) float
d) complex
View Answer
15. What is 'Console' in C#?
a) Class
b) Object
c) Method
d) Structure
View Answer
16. Which C# keyword is used to coming out from the loop?
a) break
b) continue
c) both a and b
d) none of the above
View Answer
17. What is the default value of a boolean in C#?
a) True
b) 0
c) false
d) 1
View Answer
18. What is the access modifier for a class member that can only be accessed within the same class?
a) public
b) private
c) protected
d) internal
View Answer
19. Which array property is used to get the total number of elements in C#?
a) Len
b) Length
c) Elements
d) MaxLen
View Answer
20. Which array method is used to sort an array alphabetically or in an ascending order in C#?
a) sort()
b) sorting()
c) Sort()
d) Sorting()
View Answer
21. Which keyword is used to declare an interface in C#?
a) interface
b) Interface
c) implement
d) Implement
View Answer
22. In C#, the objects created using new operator are stored in ___.
a) Cache Memory
b) Stack Memory
c) Heap Memory
d) None of the above
View Answer
23. How many catch blocks can be used with a single try block in C#?
a) One
b) Two
c) Many
d) None of the above
View Answer
24. Which access specifier should be used for Main() method in C#?
a) private
b) public
c) protected
d) internal
View Answer
25. Number of constructors a class can define is?
a) 1
b) 2
c) Any number
d) None of the mentioned
View Answer
26. What is the return type of constructors?
a) int
b) float
c) void
d) none of the mentioned
View Answer
Answer: (d) none of the mentioned
27. Which method has the same name as that of its class?
a) delete
b) class
c) constructor
d) none of the mentioned
View Answer
28. Operator used to free the memory when memory is allocated?
a) new
b) free
c) delete
d) none of the mentioned
View Answer
29. What is the return type of destructor?
a) int
b) void
c) float
d) none of the mentioned
View Answer
Answer: (d) none of the mentioned
30. Choose the base class for string() method:
a) System.Array
b) System.char
c) System.String
d) None of the mentioned
View Answer
Answer: (c) System.String
31. The Method use to remove white space from a string?
a) Split()
b) Substring()
c) Trim()
d) TrimStart()
View Answer
32. Which of these operators can be used to concatenate two or more String objects?
a) +
b) +=
c) &
d) ||
View Answer
33. An Int variable occupies _______ number of bytes.
a) 1
b) 2
c) 4
d) 8
View Answer
34. C# does not support _________ statement.
a) go
b) goto
c) break
d) continue
View Answer
35. ___________ is not an access modifier.
a) public
b) private
c) protect
d) internal
View Answer
36. Any real word entity is called __________.
a) object
b) attribute
c) characteristic
d) class
View Answer
37. __________ is method modifier that indicates a method can be overridden by a derived class.
a) Value
b) Get
c) Set
d) Virtual
View Answer
38. The ________________ is an initially undifferentiated area of memory that can be referred to by items placed on the stack
a) Linked list
b) List
c) Heap
d) Queue
View Answer
39. The default value for a boolean variable is _________.
a) 0
b) -1
c) null
d) false
View Answer
40. ________ members are accessible by any method of any class.
a) protected
b) private
c) public
d) internal
View Answer