Question:
Few Java Questions...?
Shree...
2008-01-07 17:10:28 UTC
1. can main() have only 'void' return type?
2. can applet be embedded in any java applications?
3. is there any use of applets having a main() function?
4. what is the impact of private constructors?
5. waht are atatic initializers?
6. can we assign parent object to child object?
7. what are singleton class?
Three answers:
anonymous
2008-01-07 17:31:50 UTC
Well, I only know the answer to some questions:



1. can main() have only 'void' return type?

It can have any kind of return type, but if it's not void, won't be the entry point.



2. can applet be embedded in any java applications?

I Don't understand your question



3. is there any use of applets having a main() function?

Yes: if the applet has a main() function it can run as an applet or as an application. In this case you create a Frame in main function, and add an instance of your applet derived class.



4. what is the impact of private constructors?

This means that you can't access them from any derived class, and of course, neither from another class. So you have to provide a public function that calls the private constructor - if the object has not been initailized, or to return an instance to the object, if it was initialized. This can be useful for objects that can't be instantiated.



5. waht are static initializers?

It's code that you place inside the class but it is not a method nor a constructor. You just write static{ /*code here*/}. The code inside there is called when the class is initialized.



6. can we assign parent object to child object?

I think yes, if your object has a "parent" member you can do this: mychildobj.parent=myparentobj;

Probably the top-level parent object has null as parent.





7. what are singleton class?

That's a class that can have only one instance - you can't call a constructor, you call "getInstance". If the class is not initialized, here you do it only one time, and return the current class instance. See #4
hayball
2016-12-01 08:00:38 UTC
I. double findAnswer(String a, int b) II. int findAnswer(String a, int b) The above 2 are considered as comparable. So, you may get compilation errors. With third and any of the above no project
Panther K
2008-01-07 17:17:26 UTC
did you not ask these questions earlier today?

https://answersrip.com/question/index?qid=20080106173636AABvv66&show=7#profile-info-Fj7t7JReaa


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...