can we create object for static class in java
Answer Posted / goldy
When you have to access any member of a class, you have to
create an instance of the class
Ex:- class NewClass
{
int member1;
int member2(){ }
}
create an instance
of the "NewClass" class in any class you want to
access the members.
ex:
class OtherClass{
member1;
member2; ....
OtherClass instanceOfOtherClass= new NewClass();
// instanceOfOtherClass ---> is object
}
if you declare a class as static there is no need to
create the instance ( so called object)
you can directly call the members by
class name
if NewClass were static
"NewClass.member1;"
is it clear
| Is This Answer Correct ? | 15 Yes | 15 No |
Post New Answer View All Answers
What is object-oriented paradigm?
What is natural ordering in java?
What does @override mean?
What is difference between fileinputstream and filereader in java?
Explain the Propertie sof class?
What is final modifier?
What does flag mean in java?
What is data type modifier?
What is package private scope in java?
What is the difference between final, finally and finalize() in java?
What is break and continue statement?
what methods would you overwrite in java.lang.object class?
What is the use of string and stringbuffer?
How does split work in java?
Can list be final in java?