can we make a class static without using static keyword?
Answer Posted / shadab alam
yes we can make a class static without using static keyword
We can prove it by following program.
we konw that static member of a class can be accessed by
using the class name now I will do it without static
keyword specify in sub class
Like a.abc.add()
where a is class name and abc is also class name but
without static keyword.But it executed successfully.
this proves that inner class is a static class.
using System;
static class a
{
public static void my()
{
Console.WriteLine("outer class's method");
}
class abc
{
public static void add()
{
Console.WriteLine("Inner class's
method");
}
}
public static void Main()
{
a.my();
a.abc.add();
}
}
| Is This Answer Correct ? | 6 Yes | 3 No |
Post New Answer View All Answers
Why is destructor used?
Which method cannot be overridden?
How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction
What are two types of polymorphism?
What is the difference between a mixin and inheritance?
What is inheritance in simple words?
What are the three main types of variables?
What language is oop?
Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.
What is destructor example?
What does oop mean in snapchat?
Write a c++ program to display pass and fail for three student using static member function
What does it mean when someone says I oop?
What is the diamond problem in inheritance?
What is difference between oop and pop?