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 difference between synchronize and concurrent collection in java?
What is lossy conversion in java?
How do you pass by reference?
What are the legal parameters?
Can you explain the final method modifier?
What are constructors in java?
How many types of variables are there?
What is palindrome in java?
What is multi-catch block in java?
Can private class be extended java?
Can we override private constructor in java?
How many classes can any class inherit java?
Can java run on google chrome?
Can we overload destructor in java?
Can constructor be synchronized?