a) Error while calling s.fun() due to inaccessible level
b) Error as ‘this’ reference would not be able to call ‘i’ and ‘j’
c) 1 2
d) Runs successfully but prints nothingView Answer

Answer: c
Explanation:Variable ‘i’ and ‘j’ declared with scope public in sample class are accessed using object of class ‘sample’ which is ‘s’.
Output:1 2.

6. Which of 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) None of the mentionedView Answer

Answer: a, b, c
Explanation : By definition.

7. “A mechanism that binds together code and data in manipulates, and keeps both safe from outside interference and misuse.In short it isolates a particular code and data from all other codes and data. A well-defined interface controls the access to that particular code and data.”
a) Abstraction
b) Polymorphism
c) Inheritance
d) EncapsulationView Answer

Answer: d
Explanation : By definition.

8. Select the output for the following set of code :

class z

{

publicint X;

publicint Y;

publicconstint c1 =5;

publicconstint c2 = c1 *25;

publicvoidset(int a, int b)

{

X = a;

Y = b;

}

}

class Program

{

staticvoid Main(string[] args)

{

z s =new z();

s.set(10, 20);

Console.WriteLine(s.X+" "+ s.Y);

Console.WriteLine(z.c1+" "+ z.c2);

Console.ReadLine();

}

}

a) 10 20
5 25
b) 20 10
25 5
c) 10 20
5 125
d) 20 10
125 5View Answer

Answer: c
Output : 10 20
5 125.
Explanation:Member fucntion() ‘set’ is accessed using object of class ‘z’ values are passed as parameter to ‘a’ and ‘b’.Since, variable ‘c1’ and ‘c2’ are public data member of class ‘z’.They are accessed using classname.

9. Correct way of declaration of object of the following class is ?
class name
a) name n = new name();
b) n = name();
c) name n = name();
d) n = new name();View Answer

Answer: a
Explanation:None.

10. The data members of a class by default are ?
a) protected,public
b) private,public
c) private
d) publicView Answer

Answer: c
Explanation:None.

11. Select the output for the following set of code :

class z

{

publicstring name1;

publicstring address;

publicvoid show()

{

Console.WriteLine("{0} is in city{1}", name1, " ", address);

}

}

class Program

{

staticvoid Main(string[] args)

{

z n =new z();

n.name1="harsh";

n.address="new delhi";

n.show();

Console.ReadLine();

}

}

advertisements

a) Syntax error
b) {0} is in city{1} harsh new delhi
c) harsh is in new delhi
d) Run successfully prints nothingView Answer

Answer: c
Explanation: Member function show() accessed using object of class ‘z’ which is ‘n’ as object.member().
Output : harsh is in new delhi.

12. What does the following 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 stackView Answer

Best Training

Testimonials

It was a wonderful course, a thorough study through the bits and pieces of Storage Devices and the other advancements in the SAN technology which was very informative for me. Well prepared slides, practical thoughts and fully interactive class.
— Milind - Microsoft

The depth of C coverage, the common pitfalls, the presentation by Manish and his pace were all remarkable. Gave a clear picture of the inner working of C language design.
— Shivanshu - Netapp

The course was well designed and coverage was satisfactorily deep. The linux programming assignments were designed to get a feel of real time issues and covered lot of areas of uncertainty. The project work suggested at the end of the course was invaluable.
— Somenath - EMC