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 |
c ka base kya hota hai? what is communication?
what is software engineer
#include<stdio.h> int fn(int v); main() { printf("%d\n",fn(7)); } int fn(int v) { if(v==1 || v==0) return 1; if(v%2==0) return fn(v/2)+2; else return fn(v-1)+3; }
What is the pressure in co2 cartridge in a DCP 5 kg extinguisher.
1. Design a counter which counts 0, 4, 8, 2, 6, and repeats using: 1.a using JK flip flops 1.b using T flip flops 1.c using D flip flops 2. Modify your design in question 1.a so that the circuit works according to the following function table X Y F 0 0 Clear 0 1 No Change 1 0 Parallel Loading 1 1 Count 3. Design a circuit that detects the pattern 010 in a serial input X considering: 3.a Overlapping 3.b No overlapping
I am about to face the interview panel of Indian army for UES(for more details put this address http://www.freshershome.com/jobs/index.php?post_id=15715) This is basically a post for engineering job in Indian army? This is an on campus interview. Kindly help me out with some tips or the type of questions I am about to face. Thanks.
5 Answers Indian Army, Indian Military Services, Infosys, Military Engineer Services, UES,
what is recursion in c language?
wats the difference between RS latch using NAND n NOR gate? which is to be preffered?
what is technical voice process and define it
can any one please tell me what is mean by back papers,back log,historical standing ????????? this mean history of arrears is it correct or not.........
could u please tell me where the click view tool coaching in hyderabad
Can any1 say how this prog logic works... i am weak in thread concept...pls explain step by step
Civil Engineering (5086)
Mechanical Engineering (4456)
Electrical Engineering (16639)
Electronics Communications (3918)
Chemical Engineering (1095)
Aeronautical Engineering (239)
Bio Engineering (96)
Metallurgy (361)
Industrial Engineering (259)
Instrumentation (3014)
Automobile Engineering (332)
Mechatronics Engineering (97)
Marine Engineering (124)
Power Plant Engineering (172)
Textile Engineering (575)
Production Engineering (25)
Satellite Systems Engineering (106)
Engineering AllOther (1379)