Results 1 to 2 of 2
  1. #1
    jganer is offline Member
    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Question Need help with Java questions

    I need help answering these question below cause I'm lost

    Question 11
    Which of the following is the member access operator?

    Question 11 options:

    a.+

    b..

    c.-

    d.->

    Question 12
    What will most probably happen if you omit the dot operator when accessing a method?

    Question 12 options:

    a.An exception will be thrown.

    b.The computer will crash.

    c. A syntax error will be reported.

    d. The program will execute as planned.

    Question 13
    Based on the code below, what is the value of str1?


    String sentence;
    String str1, str2, str3, str4;
    int length1;
    sentence = "First exam is on Monday.";
    str1 = sentence.substring(6, 12);
    str2 = str1.substring(0, 4);
    str3 = sentence.replace('i', '#');
    str4 = sentence.indexOf("on");
    length1 = sentence.length();
    Question 13 options:

    a. exam i

    b. exam

    c. exam is

    d. on Monday

    Question 14
    Based on the code below, what is the value of str2?


    String sentence;
    String str1, str2, str3, str4;
    int length1;
    sentence = "First exam is on Monday.";
    str1 = sentence.substring(6, 12);
    str2 = str1.substring(0, 4);
    str3 = sentence.replace('i', '#');
    str4 = sentence.indexOf("on");
    length1 = sentence.length();

    Question 14 options:

    a.Firs

    b.First

    c.Monda

    d.exam

    Question 15
    Based on the code below, what is the value of length1?


    String sentence;
    String str1, str2, str3, str4;
    int length1;

    sentence = "First exam is on Monday.";

    str1 = sentence.substring(6, 12);
    str2 = str1.substring(0, 4);
    str3 = sentence.replace('i', '#');
    str4 = sentence.indexOf("on");

    length1 = sentence.length();
    Question 15 options:

    a.20

    b.21

    c.24

    d.26

    Question 16
    Based on the code below, what is the value of str3?


    String sentence;
    String str1, str2, str3, str4;
    int length1;

    sentence = "First exam is on Monday.";

    str1 = sentence.substring(6, 12);
    str2 = str1.substring(0, 4);
    str3 = sentence.replace('i', '#');
    str4 = sentence.indexOf("on");

    length1 = sentence.length();
    Question 16 options:

    a."First exam is on Monday."

    b."F#rst exam #s on Monday."

    c."F#rst exam is on Monday."

    d."#i### #### i###########."

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    936
    Rep Power
    2

    Default Re: Need help with Java questions

    11. What is a member? And if an object has a member, how do you access it?
    12. So, we have a method with no dot. Come up with an example: myObject.doSomething(). What happens when you leave out the dot? Remember that the compiler is stupid. It can only handle what you feed it. It doesn't make stuff up.
    13. Lots of code, but we're only interested in str1. Learn to ignore the rest. Read the Javadoc for String.substring().
    14. See 13.
    15. See 13. Read the Javadoc for String.length()
    16. See 13. Read the Javadoc for String.replace()
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. Hello I am new and have some questions about Java
    By ssunlimited in forum New To Java
    Replies: 1
    Last Post: 07-08-2013, 11:37 PM
  2. New to java and have a few questions
    By schizomike in forum New To Java
    Replies: 2
    Last Post: 09-26-2012, 08:17 AM
  3. Replies: 11
    Last Post: 04-29-2012, 05:50 AM
  4. JAVA questions
    By melody in forum New To Java
    Replies: 0
    Last Post: 10-28-2009, 11:07 PM
  5. Pls i need help with these 2 Java Questions
    By jyde in forum Advanced Java
    Replies: 2
    Last Post: 10-19-2008, 07:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •