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
Can abstract class have normal methods?
What are main features of oop?
What is abstraction and encapsulation?
Why do we need 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.
what type of question are asked in thoughtworks pair programming round ?
What does no cap mean?
What are oops functions?
Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)
Can enum be null?
Is html an oop?
What is multilevel inheritance in 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 graphics
write a program to find 2^n+1 ?