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
What is encapsulation in oop?
What is abstraction oop?
What is the real time example of inheritance?
Which method cannot be overridden?
Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?
What is meant by oops concept?
can inline function declare in private part of class?
What is abstraction in oop?
What is a null tree?
What is oops and why we use oops?
How many human genes are polymorphic?
write string class as your own class in java without using any built-in function
What do you mean by Encapsulation?
What is basic concept of oop?
Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.