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 5 of 5

Thread: AP Be Prepared: concepts

  1. #1
    Member
    Join Date
    Aug 2013
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool AP Be Prepared: concepts

    Hi, I have a separate section of my textbook just for the sake of preparing for the AP exam and reviewing. There are some concepts I don't get. I would like a simple explanation of these:

    -instance variables (I'm thinking that means the parameters of an object)

    -encapsulation (I know it has to do with bundling code together and getters, setters, etc. but I can't quite figure it out)

    -information hiding (I looked at this in the review and realized I had no idea what it was)

    -public static final (I think this makes a public static method no longer changeable)

    -the "client" of a class (I looked at this in the review, and had the same realization as information hiding)

    The stuff that I haven't listed, I'm sure I get pretty well.

    I just need a SLIGHTLY better explanation of these things please. Thank you.

    sincerely, your friend, ghostheadx


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: AP Be Prepared: concepts

    I suggest doing a google search of each and coming up with your own explanations first. Then post your findings here and we'll try to correct you.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Member
    Join Date
    Aug 2013
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: AP Be Prepared: concepts

    That's a good idea. Thanks.

  4. #4
    Member
    Join Date
    Aug 2013
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: AP Be Prepared: concepts

    Here's my understanding of these things:

    Instance variables- They are what one fills in for the parameters, in a specific instance of an object.

    Encapsulation- when a variable or data is hidden from the other classes (i.e. private int John); it sort of stops certain parts of the code from being edited by other users, making the fields private

    encapsulation would be different from information hiding because information hiding is making certain variable non-accessible by a class's client classes. I don't really get the difference that well.

    As for public static final- I think that means a class that can never be edited anywhere in the code, no matter what. I'm pretty sure the data is still usable by other classes, which makes it different from encapsulation or information hiding. It's also different from private variables because it can still be accessed.

    I THINK that the client of a class (i.e. class a) would be when class b, per-say, uses information from class a and/or edits or changes information from class a. In that case, class b is one of class a's clients.

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: AP Be Prepared: concepts

    Quote Originally Posted by ghostheadx View Post
    Instance variables- They are what one fills in for the parameters, in a specific instance of an object.
    Be careful about what you mean when you say parameter, as that's a specific concept that doesn't necessarily have anything to do with instance variables. Recommended reading: Instance variable - Wikipedia, the free encyclopedia

    Quote Originally Posted by ghostheadx View Post
    Encapsulation- when a variable or data is hidden from the other classes (i.e. private int John); it sort of stops certain parts of the code from being edited by other users, making the fields private

    encapsulation would be different from information hiding because information hiding is making certain variable non-accessible by a class's client classes. I don't really get the difference that well.
    Encapsulation and information hiding are related, but it's probably inaccurate to call them the same thing. Think of encapsulation as a way to *abstract* the behavior of your code. That might be similar to how cars abstract the internal working of the engine to a few basic functions: going faster, slowing down, maybe shifting gears. You don't need to know what's going on under the hood to use those functions. A more programmatic example might be using an ArrayList: you don't need to know what's going on inside the class to use its get() and add() functions. That's encapsulation.

    Conversely, information hiding is when you purposely *hide* the way your code works. Your car might have some systems that limit your top speed. And you can't directly reassign the internal array that ArrayList uses, as that would break the encapsulation of the class.

    Quote Originally Posted by ghostheadx View Post
    As for public static final- I think that means a class that can never be edited anywhere in the code, no matter what. I'm pretty sure the data is still usable by other classes, which makes it different from encapsulation or information hiding. It's also different from private variables because it can still be accessed.
    Take the keywords one at a time. What does it mean for a class (or a variable, or a method) to be public? What does it mean for a class/variable/method to be static? What about final? Your description only mentions classes and seems to only be talking about the final keyword. And what do you mean when you say a class can never be edited in the code? Try to be more specific with your language.

    Also, it might help to put together some example programs that test all of your theories.

    Quote Originally Posted by ghostheadx View Post
    I THINK that the client of a class (i.e. class a) would be when class b, per-say, uses information from class a and/or edits or changes information from class a. In that case, class b is one of class a's clients.
    Without any more information, a client could be quite a few things.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Prepared Statement executing but not working. HEADACHE
    By sup123 in forum JDBC & Databases
    Replies: 13
    Last Post: November 28th, 2013, 02:05 PM
  2. MySQL Syntax error in Java prepared statement
    By kc120us in forum JDBC & Databases
    Replies: 4
    Last Post: March 22nd, 2012, 11:31 AM
  3. unable to execute prepared statement
    By nrao in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 11th, 2010, 08:26 PM
  4. Prepared Statement exceptions please help
    By nrao in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 11th, 2010, 08:16 PM

Tags for this Thread