What are the outputs from the two System.out.println() methods in the following code marked by red? Please write down your answer. public class Test { public static void main(String[] args) { int[] list1 = {1, 9, 2, 3}; int[] list2 = {17, 4, 5, 6}; System.out.println(list1[2]); list2 = list1; list1[0] = 7; list1[1] = 1; list2[2] = 9; System.out.println(list2[1]); } }
What are the outputs from the two System.out.println() methods in the following code marked by red? Please write down your answer. public class Test { public static void main(String[] args) { int[] list1 = {1, 9, 2, 3}; int[] list2 = {17, 4, 5, 6}; System.out.println(list1[2]); list2 = list1; list1[0] = 7; list1[1] = 1; list2[2] = 9; System.out.println(list2[1]); } }
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
What are the outputs from the two System.out.println() methods in the following code marked by red? Please write down your answer.
public class Test {
public static void main(String[] args) {
int[] list1 = {1, 9, 2, 3};
int[] list2 = {17, 4, 5, 6};
System.out.println(list1[2]);
list2 = list1;
list1[0] = 7;
list1[1] = 1;
list2[2] = 9;
System.out.println(list2[1]);
}
}
View keyboard shortcuts
EditViewInsertFormatToolsTable
12pt
Paragraph
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)