C# Programming - Classes and Objects - Discussion

Discussion :: Classes and Objects - General Questions (Q.No.5)

5. 

Which of the following is the correct way to create an object of the class Sample?

  1. Sample s = new Sample();
  2. Sample s;
  3. Sample s; s = new Sample();
  4. s = new Sample();

[A]. 1, 3
[B]. 2, 4
[C]. 1, 2, 3
[D]. 1, 4
[E]. None of these

Answer: Option A

Explanation:

No answer description available for this question.

Karthik said: (Dec 31, 2013)  
Sample s ;
s = new Sample();
This is another way of Sample s = new Sample();

Andrew Cope said: (Apr 3, 2014)  
There's nothing wrong with (4) really it just assumes that 's' has already been declared elsewhere.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.