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
Explain implementation and how is it different from conversion?
What is array size in java?
What is an exception? difference between Checked and Unchecked exception in Java
Is null in java?
What is return code?
Can we declare array without size in java?
What is the exact difference in between Unicast and Multicast object?
What is cr keyboard?
What is binary search in java?
What is meant by class and object in java?
Does java map allow duplicates?
Which of the following classes will have more memory allocated?
what do you mean by stream pipelining in java 8? Explain
What state is a thread in when it is executing?
What is difference between word and integer?