can we make a class static without using static keyword?
Answers were Sorted based on User's Feedback
Answer / rampoojan gupta
no without static key word not define the static class..
| Is This Answer Correct ? | 18 Yes | 2 No |
Answer / mamta subramanian
We cannot declare any outer class as static. There would a
compiler error if we do so.
But if it is an inner class we can declare it as static.
and it act as a static object of outer class.
| Is This Answer Correct ? | 8 Yes | 2 No |
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 |
Answer / darwin
no not at all possible with this present java framework
format.. it coukd be possible only in future if they
enhances that option to do so.. and additionallly no outer
class can be static. you can also check by compiling in
java compiler...
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / raja
see Shadab Alam, let me clear,first of all an outer class
can't be a static it could be either public or abstract or
final only, unfortunately Java Compiler can't allow other
than these three, so we can make any inner class as static.
and we can't make the behaviour of a class as static
without using "static" keyword. Thank u for asking this one.
| Is This Answer Correct ? | 1 Yes | 3 No |
what is difference b/w object based and object oriented programming language?
18 Answers Chaitanya, College School Exams Tests, Educomp, IBM, Infosys, Telko,
What is use of overloading?
What is multiple inheritance?
1.explicit call for destructor 2.calling function inside a constructor. 3.base *b-new derived delete b; 4.delete p what it will delete. 5.size of base class and derived class int i,in base class and int j in derived. 6.int i-20 int main() { int i =5; printf("%d".::i); { int i =10; printf("%d".::i); } } 7.object slicing 8.new 9.function overloading(return type). 10.class base() { virtuval fun() { ----- } } class derivied:public base() { fun() { ----- } } int main() { derived d; } 11.how static function will call in C++? 12.default structures are in C++? 13.constructors should be in public . 14.virtuval constructor not exist. 15.multilevel inhritence. destructor order.
any one please tell me the purpose of operator overloading
What is the use of fflush(stdin) in c++?
Can we call a base class method without creating instance?
What are callback functions in c++
What is an example of genetic polymorphism?
Which type does string inherit from?
WHAT IS THE DIFFERENCE BETWEEN ABSTRUCTION AND ENCAPSULATION? PLEASE EXPLAIN IT.
tel me oops defination in single line