C# Programming - Classes and Objects - Discussion

Discussion Forum : 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();
1, 3
2, 4
1, 2, 3
1, 4
None of these
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
2 comments Page 1 of 1.

Andrew Cope said:   1 decade ago
There's nothing wrong with (4) really it just assumes that 's' has already been declared elsewhere.

Karthik said:   1 decade ago
Sample s ;
s = new Sample();
This is another way of Sample s = new Sample();

Post your comments here:

Your comments will be displayed after verification.