Page 1 of 1

Java Question 1: Question 2: Question 3: Question 4:

Posted: Tue Jul 12, 2022 8:21 am
by answerhappygod
Java
Question 1:
Java Question 1 Question 2 Question 3 Question 4 1
Java Question 1 Question 2 Question 3 Question 4 1 (16.39 KiB) Viewed 30 times
Question 2:
Java Question 1 Question 2 Question 3 Question 4 2
Java Question 1 Question 2 Question 3 Question 4 2 (18.46 KiB) Viewed 30 times
Question 3:
Java Question 1 Question 2 Question 3 Question 4 3
Java Question 1 Question 2 Question 3 Question 4 3 (18.82 KiB) Viewed 30 times
Question 4:
Java Question 1 Question 2 Question 3 Question 4 4
Java Question 1 Question 2 Question 3 Question 4 4 (19.17 KiB) Viewed 30 times
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