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

Thread: New to Java some questions

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default New to Java some questions

    Hi, im new to java and am currently studying it at university, i was wondering if anyone could answer and explain these questions for me please?

    a) There are three different types of loop. Explain the difference between them
    b) Write an appropriate loop to
    i. Read in 10 names from a file
    ii. Read a number of names from a file until the word STOP is read in.
    a) Explain what an array is and describe how it can be created and used.
    b) Show the pseudo code and the code to read 10 numbers into an array and find the highest. Explain, using examples of Java, how the following could be carried out:
    a) Ask a user to input their name and address details and display the input on the screen.
    b) Read a list of names from a file, and display them on the screen.
    c) Write a list of books to a file.
    A) Using examples of code explain the uses of following
    i. A JTextField
    ii. A JPanel
    iii. A JFrame
    iv. A JLabel
    B) Show how JButtons can be used to:
    i. Close a form
    ii. To open a new form
    A) Using examples describe classes and objects and explain the relationship between them.
    B) Explain how information hiding is implemented in Object Oriented programming and why it is used.

    Thanks in advance.


  2. #2
    Member
    Join Date
    Jul 2012
    Posts
    90
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: New to Java some questions

    Quote Originally Posted by unorthadox View Post
    Hi, im new to java and am currently studying it at university, i was wondering if anyone could answer and explain these questions for me please?
    new too,but have some answers
    Quote Originally Posted by unorthadox View Post
    a) There are three different types of loop. Explain the difference between them
    the for loop is used when we know the exact number of itterations that are going to be done.It is written as this
    for(part1;part2;part3)
    part1 is executed only one time,when your code reaches this line of for loop
    then the part2 which is normally someCondition is going to be resolved in true or false.If true the loop is going to be executed,if false the for loop is going to be skipped and the body of it will never be executed.In case the part2 is true,then the body of the for loop is going to be executed.Right at the bottom of the loop the part3(which is normally is an increment or decrement) is going to be executed.Then the flow goes back to part 2 and checks it part2 is true or not an so on.

    e.g.
    for(int i=0; i<n ; i++)
    //the code here is going to be
    //executed n times
    check out the enhanced for that is used about arrays and Collections after you get some more experience.

    The while loop is going to be executed as long as the someCondition is true
    while(value<5)//someCondition is the expression value<5
    {
    //the code here is going to be executed as long as the value is smaller than 5
    }

    do
    {
    //body
    }while(someCondition);
    The do-while loop is similar to while,but it is going to be at least one time(regardless if someCondition is true or not).The body will be executed at least one time,then the someCondition is going to be resolved into true or not.If true the loop goes on,if not the flow goes after the loop.So the do while is a while that the someCondition is checked at the bottom of the loop,not the top(as the while loop).

    Quote Originally Posted by unorthadox View Post
    a) Explain what an array is and describe how it can be created and used.
    An array is a group of variables of some type,that are allocated to adjacent cells in memory.You can see some tutorial about this though

    Quote Originally Posted by unorthadox View Post
    b) Show the pseudo code and the code to read 10 numbers into an array and find the highest. Explain, using examples of Java, how the following could be carried out:
    a) Ask a user to input their name and address details and display the input on the screen.
    b) Read a list of names from a file, and display them on the screen.
    c) Write a list of books to a file.
    A) Using examples of code explain the uses of following
    i. A JTextField
    ii. A JPanel
    iii. A JFrame
    iv. A JLabel
    B) Show how JButtons can be used to:
    i. Close a form
    ii. To open a new form
    A) Using examples describe classes and objects and explain the relationship between them.
    B) Explain how information hiding is implemented in Object Oriented programming and why it is used.

    Thanks in advance.
    Many questions sound like homework and i think that we are not permitted to do someone's else hw :/

  3. #3
    Junior Member
    Join Date
    Aug 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: New to Java some questions

    Its not actually homework, there revision questions which i needed help for.
    Thanks alot for your help, appreciate it.

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

    Default Re: New to Java some questions

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/61936-new-java-few-questions.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


Similar Threads

  1. Help in java questions
    By Normal9ja in forum Java Theory & Questions
    Replies: 3
    Last Post: September 21st, 2011, 08:42 PM
  2. JAVA INTERVIEW QUESTIONS
    By kanchana1 in forum Java Theory & Questions
    Replies: 4
    Last Post: June 8th, 2011, 08:23 PM
  3. Noobie to Java questions!! :D
    By chansey123 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 17th, 2010, 11:53 AM
  4. Java Questions! :)
    By xs4rdx in forum Java Theory & Questions
    Replies: 0
    Last Post: February 21st, 2010, 08:40 AM
  5. Few very basic Java questions.
    By 01001010 in forum Java Theory & Questions
    Replies: 2
    Last Post: February 13th, 2010, 01:14 PM