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 abstraction needed?
What is Difference Between Inheritance and creating object and getting data? means Class A extends B{ B.getMethod();} (OR) Class A{ b obj=new B(); obj.getMethod(); }
Plese get me a perfect C++ program for railway/airway reservation with all details.
What type of loop is a for loop?
What is stream in oop?
What is multilevel inheritance in oop?
What is class and example?
What is the renewal class?
What is polymorphism explain?
What are the benefits of interface?
What is the problem with multiple inheritance?
What is abstraction with example?
Will I be able to get a picture in D drive to the c++ program? If so, help me out?
if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?
What is the diamond problem in inheritance?