Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/onlevelup/public_html/wp-includes/functions.php on line 6114
OCA Java SE 8 arrays and Java API quiz - On Level Up

Quiz : OCA Java SE 8 arrays and Java API quiz

oca java 8 quiz java api
Total Question : 9

In the OCA Java SE 8 Programmer I exam, you’ll be asked many questions about how to create, modify, and delete String objects, StringBuilder objects, arrays, Array-List objects, and date/time objects. To prepare you for such questions, we offre you this test online.

  • Creating and manipulating Strings
  • Test equality between Strings and other objects using == and equals().
  • Manipulate data using the StringBuilder class and its methods.
  • Declare, instantiate, initialize, and use a one-dimensional array.
  • Declare, instantiate, initialize, and use a multidimensional array.
  • Declare and use an ArrayList of a given type.
  • Create and manipulate calendar data using classes fromjava.time.LocalDateTime, java.time.LocalDate, java.time.LocalTime, java.time.format.DateTimeFormatter, java.time.Period.
  1. What is the output of the following code?

    class EJavaGuruArray {
        public static void main(String args[]) {
            int[] arr = new int[5];
            byte b = 4;
            char c = 'c';
            long longVar = 10;
            arr[0] = b;
            arr[1] = c;
            arr[3] = longVar;
            System.out.println(arr[0] + arr[1] + arr[2] + arr[3]);
        }
    }
  2. What is the output of the following code?

    class EJavaGuruArray2 {
        public static void main(String args[]) {
            int[] arr1;
            int[] arr2 = new int[3];
            char[] arr3 = {'a', 'b'};
            arr1 = arr2;
            arr1 = arr3;
            System.out.println(arr1[0] + ":" + arr1[1]);
        }
    }
  3. Which  of  the  following  are  valid  lines  of  code  to  define  a  multidimensionalint array?

  4. Which of the following statements are correct?

  5. Which of the following statements are true?

  6. Which of the following statements are correct?

  7. What is the output of the following code?

    import java.util.*;                                             // line 1
    class EJavaGuruArrayList {                                      // line 2
        public static void main(String args[]) {                    // line 3
            ArrayList ejg = new ArrayList<>();              // line 4
            ejg.add("One");                                         // line 5
            ejg.add("Two");                                         // line 6
            System.out.println(ejg.contains(new String("One")));    // line 7
            System.out.println(ejg.indexOf("Two"));                 // line 8
            ejg.clear();                                            // line 9
            System.out.println(ejg);                                // line 10
            System.out.println(ejg.get(1));                         // line 11
        }                                                           // line 12
    }                                                               // line 13
    
  8. What is the output of the following code?

    class EJavaGuruString {
        public static void main(String args[]) {
            String ejg1 = new String("E Java");
            String ejg2 = new String("E Java");
            String ejg3 = "E Java";
            String ejg4 = "E Java";
            do
                System.out.println(ejg1.equals(ejg2));
            while (ejg3 == ejg4);
        }
    }
  9. What is the output of the following code?

    class EJavaGuruString2 {
        public static void main(String args[]) {
            String ejg = "game".replace('a', 'Z').trim().concat("Aa");
            ejg.substring(0, 2);
            System.out.println(ejg);
        }
    }

Retated posts