Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Is it possible to achieve the encapsulation without class

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Is it possible to achieve the encapsulation without class

    I mean in Java


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,066
    My Mood
    Mellow
    Thanks
    184
    Thanked 652 Times in 639 Posts

    Default Re: Is it possible to achieve the encapsulation without class

    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?

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Is it possible to achieve the encapsulation without class

    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?

  4. #4
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,659
    Thanks
    25
    Thanked 325 Times in 302 Posts

    Default Re: Is it possible to achieve the encapsulation without class

    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/

  5. #5
    Junior Member
    Join Date
    Jun 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Is it possible to achieve the encapsulation without class

    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?

  6. #6
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Is it possible to achieve the encapsulation without class

    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.

Similar Threads

  1. Help with Encapsulation and Value Methods! Please and Thanks!
    By nickjesus3 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 10th, 2012, 12:31 AM
  2. Doubt in Encapsulation concept
    By nareshn in forum Object Oriented Programming
    Replies: 1
    Last Post: January 19th, 2011, 01:20 AM
  3. Trying to achieve Movie Style Rolling Credits
    By javanoob123 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 10th, 2011, 07:02 PM
  4. Encapsulation question regarding ArrayLists
    By LDM91 in forum Collections and Generics
    Replies: 3
    Last Post: October 27th, 2010, 11:51 AM