Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

    FileShortTitle:Mock Question 1-7 FileLongTitle:OCA Mock Question Core Java APIs 1-7 FileTag:Mock Question FileID:longtutorial/Java/OCA_Java_SE_8_Core_Java_APIs/Q1-7. xml===SectionShortTitle:Question SectionLongTitle:Question SectionContent:

    <p>Which are the results of the following code?(Choose all that apply)</p><myPreCode>
    public class Main {
        public static void main(String[] argv) {
            String numbers = "012345678";
            System.out.println(numbers.substring(1, 3));
            System.out.println(numbers.substring(7, 7));
            System.out.println(numbers.substring(7));
        }
    }</myPreCode><ol type="A">
    <li>12</li>
    <li>123</li>
    <li>7</li>
    <li>78</li>
    <li>A blank line.</li><li>An exception
    is thrown.</li><li>The code
    does not compile.</li></ol>===SectionShortTitle:
    Answer SectionLongTitle:
    Answer SectionContent:

    <input type='button' class='btn btn-primary' data-toggle='collapse' data-target='#answer' 
value='Click for the answer'/>
<br/><br/><div id='answer' class='collapse out'>
  <p>
  A, D, E. 
  </p></div>
===
SectionShortTitle:Note
SectionLongTitle:Note
SectionContent:

<p>substring()
    has two forms.</p>

    <p>The first
    takes the
    index to
    start with
    and the
    index to
    stop immediately before.</p>

    <p>The second
    takes just
    the index
    to start
    with and
    goes to
    the end
    of the String.</p>

    <p>indexes are
    zero based.</p>

    <p>The first
    call starts
    at index 1
    and ends
    with index 2
    since it
    needs to
    stop before index 3.</p>

    <p>
    The second
    call starts
    at index 7
    and ends
    in the
    same place, resulting
    in an
    empty String.
    This prints
    out a
    blank line.</p>

    <p>The
    final call starts
    at index 7
    and goes
    to the
    end of
    the String.</p>