Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is lossy conversion in java?

1138


Can two objects have same hashcode?

959


Why java is object oriented?

973


What are the different collection views provided by maps?

947


How many ways can an argument be passed to a subroutine and explain them?

979


What is nested interface?

972


What do you mean by default constructor in java?

1025


What will be the initial value of an object reference which is defined as an instance variable?

1095


Is java a security risk?

970


Explain a situation where finally block will not be executed?

980


How would overload a function based on return type?

929


What is an abstract class and what is it’s purpose?

921


Is zero a positive integer?

1005


What are data structures in java?

929


Why are parameters used in functions?

958