I mean in Java
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
Members have full access to the forums. Advertisements are removed for registered users.
I mean in Java
Other than answering a bad quiz or test question correctly, what possible value is there in knowing the answer to this question? How will it change or not change anything you do?
It was a question at JAVA testing despite the answer was open. I wrote that NO. But for exaple main() method is public so maybe it is possible. Anyway it is one of the main question here for the software firm. I have also asked it in CHAT but do not know how finmd it here? I would be grateful to get answer as I could be asked again it in interview after testing?
Well the main method still needs to be in a class.
NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:
When asking for help, please follow these guidelines to receive better and more prompt help:
1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
2. Give full details of errors and provide us with as much information about the situation as possible.
3. Give us an example of what the output should look like when done correctly.
Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/
So it means that we could not realize no method, no produce variable without class. So it is impossible unrealize (execute) encapsulation without class. Is it right?
In Java 8 there are plans to implement Lambda expressions/Closures. I haven't read through the details on how these features will work in Java specifically, but in other languages with closures these do offer encapsulation.
In a sense methods also offer encapsulation of an action, but they don't offer encapsulation in the general sense that classes and closures do. I can't think of any other encapsulation mechanisms in Java.