if all user defined constructor of a class made private,can
we create an object of that class?justify your answer with
an example.
Answers were Sorted based on User's Feedback
Answer / mashruk
Yes, we can create an object of that class, but, we cannot
extend it.
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / 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 |
please kindly send me the details about courses that are offered in nda
how to send request to the direct server rather than proxy server
3. Tell me about a time when you had too many things to do and you were required to prioritize your tasks.
what is the address bus length of an 8086 microprocessor?
I am an Electrical engineering ( electrical back round ) ,can i get hvac Water system design details to easy understand ,i am working past 15years in Pharmaceuticals company with Engineering depart.
0 Answers Archimedis Healthcare,
How can I boldly face the interview? Request:I am eagerly waiting for your replay.
A rectangular sheet dimensions a x b is to be made into an open-topped box by cutting a square of side h from each corner and folding the 4 sides up. Find the value of h which allows the maximum volume of the box?
A company canteen needs an automated system for its food and beverage management. The canteen receives food and beverage items from different distributors. All the non perishable items are stored in the store-room and the perishable items are put in the fridge. The manager should be able to add, delete or update food and beverage items onto the system and perishable and non perishable item details are to be stored separately. Both waiters and the cooks should be able to update the perishable items, but only the cooks should be allowed to update the non perishable items. Both cooks and waiters are not allowed to add or delete any items that are entered. identify the Schema, Table , Fields
Explain your experience in Lean Manufacturing and Six Sigma methods?
hi , anyone plz end nic model papers to my id
pls its urgent!!!!!!! can u tell me which companies are hiring fresher for industrail training???i know only two companies cmc which is in bandra n biz tech solution in kandivali. can anyone knows other companies??how much fees r they taking?? what about biz technology?this company is good to join if anyone has did d industrial training in biz technology then pls reply as urgent as possible. thank you ....waiting for replyyyyy
what is difference between value datatype and object datattype