C# Programming - Classes and Objects
Exercise : Classes and Objects - General Questions
- Classes and Objects - General Questions
1.
Which of the following statements is correct about the C#.NET code snippet given below?
class Student s1, s2; // Here 'Student' is a user-defined class.
s1 = new Student();
s2 = new Student();
2.
Which of the following statements is correct about the C#.NET code snippet given below?
class Sample
{
private int i;
public Single j;
private void DisplayData()
{
Console.WriteLine(i + " " + j);
}
public void ShowData()
{
Console.WriteLine(i + " " + j);
}
}
3.
Which of the following statements are correct?
- Instance members of a class can be accessed only through an object of that class.
- A class can contain only instance data and instance member function.
- All objects created from a class will occupy equal number of bytes in memory.
- A class can contain Friend functions.
- A class is a blueprint or a template according to which objects are created.
4.
Which of the following statements is correct?
5.
Which of the following is the correct way to create an object of the class Sample?
- Sample s = new Sample();
- Sample s;
- Sample s; s = new Sample();
- s = new Sample();
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers