C# Programming - Classes and Objects - Discussion

Discussion Forum : Classes and Objects - General Questions (Q.No. 2)
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);
    }
}
j cannot be declared as public.
DisplayData() cannot be declared as private.
DisplayData() cannot access j.
ShowData() cannot access to i.
There is no error in this class.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
10 comments Page 1 of 1.

Okechukwu said:   9 years ago
@Uday, we mustn't declare static void main in the class shown in the program.

Static void main can be declared in another class embedded within the same program.

Uday said:   9 years ago
Single is value data type, here we are not declaring static void main, so there is an error.

Shouvith said:   10 years ago
Can you give any example single type data?

AJESH said:   1 decade ago
What is the range of single data type?

Vinod singh said:   1 decade ago
In single data type variable we can store value type data.

Kuldeep said:   1 decade ago
What type of data can be stored in the Single type Variable ?

Vipin said:   1 decade ago
Single is data type like float, double in c#.

Shital said:   1 decade ago
What is is single?

Jerome Prince said:   1 decade ago
Even-though I declared as private, within this class I can accessible so no error.

Prashant said:   1 decade ago
If i is declare inside the class then i is no accessible in another class declaration and for j by default is public.

Post your comments here:

Your comments will be displayed after verification.