Welcome Guest | Sign in | Register
Inheritance - Discussion Page For Q.2855 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Inheritance > Questions and Answers

Q: class manager {
private manager() {
System.out.println(1); }
Private void manager(){
System.out.println(2); }
public static void main(String args[]){
new manager(); } }
A. 1 B. 2
C. compile time error D. runtime error

Answer and Explanation

Answer:1

Explanation:
if constructor is private you can not create an object from other class if you try to create then it will throw an compile time error , if you want to create then create from same class. Here we are creating from same class so it will display 1.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.