100% found this document useful (2 votes)
115 views16 pages

Visual Programming C# MCQS

The document contains a series of multiple-choice questions (MCQs) related to Visual Programming in C#. Each question tests knowledge on various aspects of C# programming, including data types, operators, control structures, and object-oriented concepts. Answers are provided for each question, making it a useful resource for exam preparation or self-assessment.

Uploaded by

Arslan Bukhari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
115 views16 pages

Visual Programming C# MCQS

The document contains a series of multiple-choice questions (MCQs) related to Visual Programming in C#. Each question tests knowledge on various aspects of C# programming, including data types, operators, control structures, and object-oriented concepts. Answers are provided for each question, making it a useful resource for exam preparation or self-assessment.

Uploaded by

Arslan Bukhari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Visual Programming C# Mcqs

1. How many Bytes are stored by ‘Long’ Data type in C# .net?


a) 8
b) 4
c) 2
d) 1
Answer: a
2. Correct Declaration of Values to variables ‘a’ and ‘b’?
a) int a = 32, b = 40.6;
b) int a = 42; b = 40;
c) int a = 32; int b = 40;
d) int a = b = 42;
Answer: c
3. Which Conversion function of ‘Convert.TOInt32()’ and ‘[Link]()’ is
efficient?
a) ii
b) Both i, ii
c) i
d) None of the mentioned
Answer: a
4. Correct way to assign values to variable ‘c’ when int a=12, float b=3.5, int c;
a) c = a + b;
b) c = a + int(float(b));
c) c = a + convert.ToInt32(b);
d) c = int(a + b);
Answer: c
5. What will be the output of the following C# code?

static void Main(string[] args)


{
float a = 10.553f;
long b = 12L;
int c;
c = Convert.ToInt32(a + b);
[Link](c);
}

a) 23.453
b) 22
c) 23
d) 22.453
Answer: c
6. Which is the String method used to compare two strings with each other?
a) Compare To()
b) Compare()
c) Copy()
d) ConCat()
Answer: b
7. For two strings s1 and s2 to be equal, which is the correct way to find if the
contents of two strings are equal?
a) if(s1 = s2)
b)int c;
c = [Link](s2);
c) if (s1 is s2)
d) if(strcmp(s1, s2))
Answer: b
8. ‘Implicit Conversion’ follows the order of conversion as per compatibility of
data type as:
a) float < char < int
b) char < int < float
c) int < char < float
d) float < int < char
Answer: b
9. What will be the output of the following C# code?
static void Main(string[] args)
{
float a = 16.4f;
int b = 12;
float c;
c = a * ( b + a) / (a - b) ;
[Link]("result is :" +c);
[Link]();
}
a) 106
b) 104.789
c) 105.8546
d) 103.45
Answer: c
10. What will be the output of the following C# code?

static void Main(string[] args)


{
int a, b, c, x;
a = 80;
b = 15;
c = 2;
x = a - b / (3 * c) * ( a + c);
[Link](x);
[Link]();
}
a) 78
b) -84
c) 80
d) 98
Answer: b
11. What will be the output of the following C# code?

int i, j = 1, k;
for (i = 0; i < 3; i++)
{
k = j++ - ++j;
[Link](k + " ");
}
a) -4 -3 -2
b) -6 -4 -1
c) -2 -2 -2
d) -4 -4 -4
Answer: c
12. Which of the following is/are not Relational operators in C#.NET?
a) >=
b) <>=
c) Not
d) <=
Answer: b
13. What will be the output of the following C# code?

m = 5;
int y;
1. y = m++;
2. y = ++m;
a) y = 5, m = 6 ; y = 5, m = 5
b) y = 6, m = 6; y = 7, m = 6
c) y = 5, m = 6; y = 7, m = 7
d) y = 5, m = 6; y = 7, m = 8
Answer: c
14. What will be the output of the following C# code?

m = 5;
int y;
1. y = m++;
2. y = ++m;
a) y = 5, m = 6 ; y = 5, m = 5
b) y = 6, m = 6; y = 7, m = 6
c) y = 5, m = 6; y = 7, m = 7
d) y = 5, m = 6; y = 7, m = 8
Answer: c
15. Which among the following is a conditional operator?
a) ‘:?’
b) ?;
c) ?:
d) ??
Answer: c
16. What will be the output of the following C# code?

static void Main(string[] args)


{
int i = 5;
for (; [Link](Convert.ToInt32(i)); [Link](i--)) ;
[Link]();
}
a) 4 3 2 1
b) 3 2 1
c) 5 4 3 2 1
d) 2 1
Answer: c
17. Which statement is correct among the mentioned statements?
i. The for loop works faster than a while loop
ii. for( ; ; )implements an infinite loop
a) Only i is correct
b) Only ii is correct
c) Both i and ii are correct
d) Both i and ii are incorrect
Answer: b
18. What will be the output of the following C# code?

static void Main(string[] args)


{
float s = 0.1f;
while (s <= 0.5f)
{
++s;
[Link](s);
}
[Link]();
}
a) 0.1
b) 1.1
c) 0.1 0.2 0.3 0.4 0.5
d) No output
Answer: b
19. Which of the following is used to define the member of a class externally?
a) :
b) ::
c) #
d) none of the mentioned
Answer: b
20. The operator used to access member function of a class?
a) :
b) ::
c) .
d) #
Answer: c
21. What is the most specified using class declaration?
a) type
b) scope
c) type & scope
d) none of the mentioned
Answer: c
22. Which of the following statements about objects in “C#” is correct?
a) Everything you use in C# is an object, including Windows Forms and controls
b) Objects have methods and events that allow them to perform actions
c) All objects created from a class will occupy equal number of bytes in memory
d) All of the mentioned
Answer: d
23. The data members of a class by default are?
a) protected, public
b) private, public
c) private
d) public
Answer: c
24. What does the following C# code imply?
csharp abc;
abc = new charp();
a) Object creation on class csharp
b) Create an object of type csharp on heap or on stack depending on the size of
object
c) create a reference c on csharp and an object of type csharp on heap
d) create an object of type csharp on stack
Answer: c
25. How many values does a function return?
a) 0
b) 2
c) 1
d) any number of values
Answer: c
26. The process of defining two or more methods within the same class that
have same name but different parameters list?
a) Method overloading
b) Method overriding
c) Encapsulation
d) None of the mentioned
Answer: a
27. What is a correct syntax to output "Hello World" in C#?
a)cout << "Hello World";
b)[Link]("Hello World");
c)print ("Hello World");
d)[Link]("Hello World");
Answer: a
28. Which data type is used to create a variable that should store text?
a)Txt
b)str
c)string
d)myString
Answer: c
29. Which operator is used to add together two values?
a)The & sign
b)The * sign
c)The + sign
Answer: c
30. How do you create a method in C#?
a)MyMethod.
b)(MyMethod)
c)myMethod[]
d)MyMethod()
Answer: d
31. Which keyword is used to create a class in C#?
a)MyClass
b)className
c)class()
d)class
Answer: d
32. Which keyword is used to create a class in C#?
a)MyClass
b)className
c)class()
d)class
Answer: d
33. What is the correct way to create an object called myObj of MyClass?
a)class MyClass = new myObj();
b)MyClass myObj = new MyClass();
c)class myObj = new MyClass();
d)new myObj = MyClass();
Answer: b
34. What will be the output of the following C# code?

public static void Main(string[] args)

p();

void p()

[Link]("hi");
}

a) Compile time error


b) hi
c) hi infinite times
d) None of the mentioned
Answer: a
35. The operator used to access member function of a class?
a) :
b) ::
c) .
d) #
Answer: c
36. A _______ is an identifier that denotes a storage location
A. Constant
B. Reference type
C. Variable
D. Object
Ans: C
37. C# has _______ operator, useful for making two way decisions.
A. Looping
B. Functional
C. Exponential
D. Conditional
Ans: D
38. In C#, having unreachable code is always an _____.
A. Method
B. Function
C. Error
D. Iterative
Ans: C
39. The ______ are the Graphical User Interface (GUI) components created for
web based interactions..
A. Web forms
B. Window Forms
C. Application Forms
D. None of the above
Ans: B
40. In Microsoft Visual Studio, ______ technology and a programming language
such as C# is used to create a Web based application.
A. JAVA
B. J#
C. [Link]
D. [Link]
Ans: D
41. The controls available in the tool box of the ______ are used to create the
user interface of a web based application.
A. Microsoft visual studio IDE
B. Application window
C. Web forms
D. None of the above
Ans: A
42. The infrastructure that supports these dynamic operations at run time is
called the__________.
[Link]
[Link]
[Link]
[Link]
Ans: D
43. Web Forms consists of a _______ and a _________ .
A. Template, Component
B. CLR, CTS
C. HTML Forms, Web services
D. Windows, desktop
Ans: A
44. C# doesnot support:
A. abstraction
B. polymorphism
C. multiple inheritance
D. inheritance
Ans: C
45. Which of the followings are value types in C#?
a)Int32
b)Double
c)Decimal
d)All of the above
Ans: d
46. ______ namespace is required for windows forms application.
(A) using [Link];
(B) using [Link];
(C) using [Link];
(D) using System;
Answer: C
47. _____ the entry point of windows application.
(A) [Link]
(B) [Link]
(C) [Link]
(D) None of these
Answer: A
48: _____ is fully loaded with the controls in design view.
(A) Form
(B) Toolbox
(C) Controls
(D) Design
Answer: B
49: _____ short cut key is used to see form(s) property window.
(A) F1
(B) F2
(C) F3
(D) F4
Answer:D
50: _____ fires a command/event when a mouse click occurs or the Enter or
ESC key is pressed.
(A) Button
(B) Label
(C) TextBox
(D) None of these
Answer: A
51.

You might also like