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...

if all user defined constructor of a class made private,can
we create an object of that class?justify your answer with
an example.

Answer Posted / sp

Object can be created only within the same class but not in
another class (including sub class)

Eg:
// valid instantiation
public class ClassWithPrivateConstructors {

private ClassWithPrivateConstructors() {
System.out.println("object created");
}
public static void main(String args[]) {
ClassWithPrivateConstructors t = new
ClassWithPrivateConstructors();
}
}

//invalid instantiation - subclass
public class SubClassWithPrivateConstructors extends
ClassWithPrivateConstructors {
public NewClassConstructorTest(String name) {
//implicitly super() constructor in super
class is invoked.
System.out.println("New sub class object created" + name);
}
}

//invalid instantiation - reference class
public class ClassWithPrivateConstructorsTest {

public ClassWithPrivateConstructorsTest() {
ClassWithPrivateConstructors c = new
ClassWithPrivateConstructors();
}
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

hey frnds..i have taken an emergency interview date of 21st july and my school is starting from 8th sept...i was continuously checking the date from 10 days but was not able to get a normal date...so can i get a rejection on this, that i have taken an emergency date.??????

1794


HI i have 2 year manual testing exp from MNC in pune but due to some reason i am looking job in testing . Friends hepl me to get the job i am not getting calls. alim24@gmail.com.09860643281

2402


What are the main assumptions that we make when we model potential flow?

1055


What do you think determines a person's progress in a good company?

11956


Explain the difference between RAM and ROM? What is “Volatile Memory

1418


How EVA granules manufactured (I wanted to know the manufacturing process). (Virgin Granules) and what are the Raw Materials used.

1847


how many clusters are generated by k-means algorithm?

1553


What is the actual procedure of charging synthetic oil if the machine is under positive refrigerant pressure.

1715


WHAT ARE THE ADVANTAGE OF SYSTEM ENGINEER

1916


what are purchase order , sales order idoc names and idoc types

2087


the controller valve fisher error: travel ??? not output input ok

1938


in HVAC how does the chiller functioned .. and what is the chiller cyclic process

2127


1. what is the opportunity in hardware & networking in future? 2.how many courses r in networking that fulfill market requrment? 3.who is better for career MCSE or CCNA ,UNIX ?

2067


What is The Need of Template?

1982


What is histogram? why and how it is used?

1940