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
How dead lock situation occurs in java and how you can identify it?
What is the largest data type in java?
why are wait(), notify() and notifyall() methods defined in the object class? : Java thread
What is an association?
What is the difference between a factory and abstract factory pattern?
Is 0 an even number?
What are inbuilt functions in java?
Why is stringbuffer thread safe?
Break statement can be used as labels in java?
What is finalize() function in java?
What is the difference between import java.util.date and java .util?
What is ph and buffers?
Can a lock be acquired on a class in java programming?
What is sorting algorithm in java?
Is it possible to instantiate the abstract class?