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 |
how to generate linked implementation of sparse matrix?
DIRECTIONS for questions 8 and 9: Refer to the data below and answer the questions that follow. There are seven chapters in a mathematics book - A, B, C, D, E, F, and G. The instructor has to follow certain rules while teaching them. i. E cannot be taught before B and C. ii. D should be taught before C and G. iii. B cannot be taught before G. iv. F cannot be taught before C, D, and G. v. A should be taught before B is taught and the two should not be taught consecutively. Q8. If only four chapters are taught, which of the following has to be necessarily false? a) The instructor can get away without teaching F. b) The instructor can avoid teaching E. c) The instructor can avoid teaching C. d) The instructor can avoid teaching G. Q9. If only four chapters are to be taught, which of the following is necessarily true? a) A has to be taught. b) D has to be taught. c) B has to be taught. d) C has to be taught. Q8. If only four chapters are taught, which of the following has to be necessarily false? a) The instructor can get away without teaching F. b) The instructor can avoid teaching E. c) The instructor can avoid teaching C. d) The instructor can avoid teaching G. Q9. If only four chapters are to be taught, which of the following is necessarily true? a) A has to be taught. b) D has to be taught. c) B has to be taught. d) C has to be taught.
1. Describe a time when you anticipated potential problems and developed Preventive measures.
b. how the type of transmission medium can affect the performance of a network
If a stored procedure is taking a table data type, how it looks?
write a c program which accept input as:Anu.B.Kapur and give out as:Kapur.A.B using pointers
how is the config take place and from reciever side how will process the data into internal table
what is advantages and disadvantages of vlan?
I attended an interview with CGI last week for network engineer and here are the questions that might help you guys who are going to attend interviews.
In HSE what is Lost time accident? why it is to be reported within 48 hrs to gov.authorities ?
hi........ i am a student of computer science. i want to earn some money on net so that i can help my parents. so please suggest me some sites which give online part time jobs without any registration charges. please help me. i will be very thankful to you. varinder.
sir ,,kindly provide me 10 year old solved question papers of gate ,i am from CS. branch...