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

Thread: Java Fundamental

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

    Default Java Fundamental

    Which one of the following is an advantage of providing accessor methods in a class, rather than making the class's fields publicly accessible?

    Choice 1 Accessor methods can ensure data integrity by validating the proposed value. Any value could be written to a public field.

    Choice 2 Accessor methods can prevent memory overwrites by performing bounds checks on arrays. Public fields are not checked for bounds overrun.

    Choice 3 The accessor methods are automatically available to other tasks using the RMI subsystem. Public fields cannot be remotely accessed.

    Choice 4 Accessor methods improve performance by avoiding a context switch in the bytecode interpreter. Accessing a public field requires loading the object's data pointer.

    Choice 5 Accessor methods can be made accessible to classes in other packages. Public fields are only usable from the same package.


    I think choice 4 is the correct answer. please advise


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

    Default JavaFundamental2

    How do you store a copy of an object at the same time other threads are changing the object's properties?

    Choice 1 You do not need to do anything special since all ObjectOutputStream methods are synchronized.

    Choice 2 Clone the object in a block synchronized on the object and serialize the clone.

    Choice 3 Implement java.io.Externalizable instead of java.io.Serializable.

    Choice 4 Give the thread performing storage a higher priority than other threads.

    Choice 5 Override writeObject() in ObjectOutputStream to make it synchronized.


    I think choice1 is the correct answer. please sugest.

  3. #3
    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: JavaFundamental2

    Does the API agree with your answer? What does your answer even mean- even if ObjectOutputStream's methods were synchronized, how does that prevent another Thread from changing the Object's properties?
    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!

  4. #4
    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: Java Fundamental

    Why do you think choice 4 is correct?
    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!

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

    Default JV3

    Invoking a method can represent a significant amount of overhead in a program; as such, some compilers will perform an optimization called "method inlining." This optimization will remove a method call by copying the code inside the method into the calling method.

    Referring to the text above, which one of these statements is true?

    Choice 1 The developer of inlined methods must copy and paste the code that is to be inlined into another method.

    Choice 2 The performance benefits should be balanced against the increased chance of a RuntimeException.

    Choice 3 It allows the use of getter and setter methods to execute nearly as fast as direct access to member variables.

    Choice 4 It prevents code from executing in a way that follows object-oriented encapsulation.

    Choice 5 This optimization will only occur if the relevant methods are declared volatile.



    Pls suggest which is most appropriate choice. I think its choice3

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

    Default JV$

    Which one of the following is a checked exception?

    Choice 1 Error

    Choice 2 NullPointerException

    Choice 3 ArithmeticException

    Choice 4 RuntimeException

    Choice 5 Exception


    I am really confused with the options given. clearly options1 to 4 are not checked. left with choice 5 only.

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

    Default JV5

    Which statement about JavaBeans is NOT true?

    Choice 1 A JavaBean is a re-usable software component.

    Choice 2 A JavaBean is immutable; it cannot contain variable data.

    Choice 3 A JavaBean can contain variable data.

    Choice 4 A JavaBean must be serializable.

    Choice 5 A JavaBean generally has one setter for every getter.


    Chocie 2 for me,

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

    Default JV6

    Which one of the following is an advantage of providing accessor methods in a class, rather than making the class's fields publicly accessible?

    Choice 1 Accessor methods can ensure data integrity by validating the proposed value. Any value could be written to a public field.

    Choice 2 Accessor methods can prevent memory overwrites by performing bounds checks on arrays. Public fields are not checked for bounds overrun.

    Choice 3 Accessor methods can be made accessible to classes in other packages. Public fields are only usable from the same package.

    Choice 4 Accessor methods improve performance by avoiding a context switch in the bytecode interpreter. Accessing a public field requires loading the object's data pointer.

    Choice 5 The accessor methods are automatically available to other tasks using the RMI subsystem. Public fields cannot be remotely accessed.

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

    Default JV7

    What java.util class method is used to sort an array of beans, where the method can specify the order of sorting?

    Choice 1 Collections.sort(beans);

    Choice 2 Algorithms.quickSort(beans);

    Choice 3 ArrayList.sort(beans, ASCENDING);

    Choice 4 Arrays.sort(beans, comparator);

    Choice 5 ArrayList.sort(beans);

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

    Default JV8

    a. final

    b. abstract

    c. virtual

    d. static

    Which of the keywords above are often used with polymorphic methods?

    Choice 1 a

    Choice 2 b

    Choice 3 c

    Choice 4 a, b, and d

    Choice 5 a, b, c, and d


    Choice 1?

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

    Default JV9

    Scenario

    a. Scrollable is an interface.

    b. Writable is an interface.

    c. TextScreen is an abstract class.

    d. VideoScreen is a class that extends TextScreen and implements both Scrollable and Writable.

    Referring to the scenario above, which one of the following statements is always true?

    Choice 1 A Scrollable can be cast to a VideoScreen.

    Choice 2 A VideoScreen cannot be passed to a method that expects a TextScreen.

    Choice 3 A VideoScreen cannot be passed to a method that expects a Scrollable.

    Choice 4 A VideoScreen cannot be passed to a method that expects a Writable.

    Choice 5 A VideoScreen can be cast to a Scrollable.


    Choice 5?

  12. #12
    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: JV9

    You keep posting these incessant questions in the "what's wrong with my code" section, despite not having any code.

    You also keep posting your answer without any support, despite being asked to back up your statements.

    Please go back and edit your posts to include your thoughts, as well as more descriptive titles. Simply posting your homework here is not acceptable.
    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!

  13. #13
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JV3

    Threads merged and locked. Please post one question at a time - these forums are not a homework service, nor a 'is this right' service. We are unpaid volunteers that enjoy helping people learn - please keep this in mind when posting questions of this sort.

  14. The Following User Says Thank You to copeg For This Useful Post:

    KevinWorkman (June 3rd, 2013)

  15. #14
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Java Fundamental

    Please do not post the same question multiple times on the forum.

    Threads merged.

    So which is it, 1 or 4? Why?

    --- Update ---

    More of the same posts, all merged into one pile of history.

    If you want any kind of reply please show some kind of effort or attempt to do your own homework.

  16. The Following 2 Users Say Thank You to jps For This Useful Post:

    copeg (June 3rd, 2013), KevinWorkman (June 4th, 2013)

Similar Threads

  1. Java Fundamental questions
    By jmsrajeev in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 3rd, 2013, 02:34 AM
  2. Fundamental knowledge before starting Java programming.
    By wsung in forum Java Theory & Questions
    Replies: 1
    Last Post: October 7th, 2012, 05:42 AM