Java Question 1: Question 2: Question 3: Question 4:
Posted: Tue Jul 12, 2022 8:21 am
Java
Question 1:
Question 2:
Question 3:
Question 4:
What type of error (if any) is in the code below? ArrayList words = new ArrayList(); words.add("apple"); words.add("banana"); String first = words.get(0); compile time error only run-time error only O compile time and run-time error none of these is correct (there are no errors)
What is true after the execution of the following code? ArrayList<String> arrayList new ArrayList<String>(); arrayList.add("a"); arrayList.add("b"); arrayList.add("c"); arrayList.remove("b"); none of these are correct the list will contain ["a", "c"] a runtime exception will be thrown the list will contain ["a", null, "c"]
What is true after the execution of the following code? ArrayList<Integer> arrayList = new ArrayList<>(3); arrayList.add (45); arrayList.add(62); arrayList.add(33); arrayList.add (19); arrayList will contain 4 values O arrayList will contain 3 values a runtime exception will be thrown there will be a compiler error
What is true after the execution of the following code? ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("a"); arrayList.add("b"); arrayList.add("c"); System.out.println(arrayList.remove("x")); a runtime exception will be thrown false is printed O there is a compiler error -1 is printed "x" is printed
Question 1:
Question 2:
Question 3:
Question 4:
What type of error (if any) is in the code below? ArrayList words = new ArrayList(); words.add("apple"); words.add("banana"); String first = words.get(0); compile time error only run-time error only O compile time and run-time error none of these is correct (there are no errors)
What is true after the execution of the following code? ArrayList<String> arrayList new ArrayList<String>(); arrayList.add("a"); arrayList.add("b"); arrayList.add("c"); arrayList.remove("b"); none of these are correct the list will contain ["a", "c"] a runtime exception will be thrown the list will contain ["a", null, "c"]
What is true after the execution of the following code? ArrayList<Integer> arrayList = new ArrayList<>(3); arrayList.add (45); arrayList.add(62); arrayList.add(33); arrayList.add (19); arrayList will contain 4 values O arrayList will contain 3 values a runtime exception will be thrown there will be a compiler error
What is true after the execution of the following code? ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("a"); arrayList.add("b"); arrayList.add("c"); System.out.println(arrayList.remove("x")); a runtime exception will be thrown false is printed O there is a compiler error -1 is printed "x" is printed