Question

public static void main(String[] args) { //Given the following code : int[][] array2D = {{3, 4,...

public static void main(String[] args) {

//Given the following code :

int[][] array2D = {{3, 4, 5, 1}, {3,6,1,2}, {1,3,6,5};

Answer :

1- All values ​​of array2D are automatically 0 ? Yes or No

2- What is the value of array2D [3] .length ?________

3-  The value that array2D.length shows is 12: Yes or No ?

4- Assign the value of 12 to the element in the third row, fourth column :

5- the value obtained when calculating array2D [1] [1] + array2D [2] [3] is?

Homework Answers

Answer #1

Solution 1:
No. Because array2D array is already specified with elements.

Solution 2:

For array2D[3].length will give you ArrayIndexOutOfBoundException. Because array is of length of three, it will starts from zero index, so the highest index will be two.

Solution 3:

No, the length is 3.

length to determine the number of rows in a 2D array because the length of a 2D array is equal to the number of rows it has.

Solution 4:

public class Main
{
   public static void main(String[] args) {
       int[][] array2D = {{3, 4, 5, 1}, {3,6,1,2}, {1,3,6,5}};
       array2D[2][3]=12;
       System.out.println(array2D[2][3]);
       }
}

Solution 5:

The value is 18.

public class Main
{
   public static void main(String[] args) {
       int[][] array2D = {{3, 4, 5, 1}, {3,6,1,2}, {1,3,6,5}};
       array2D[2][3]=12;
       System.out.println(array2D [1] [1] + array2D [2] [3]);
       }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Consider the following Java program : public static void main (string args [ ]) { int...
Consider the following Java program : public static void main (string args [ ]) { int result, x ; x = 1 ; result = 0; while (x < = 10) { if (x%2 == 0) result + = x ; + + x ; } System.out.println(result) ; } } Which of the following will be the output of the above program? A. 35 B. 30 C. 45 D. 35 2. public static void main(String args[]) { int i =...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {       ...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {        Stack<Integer> new_stack = new Stack<>();/* Start with the empty stack */        Scanner scan = new Scanner(System.in);        int num;        for (int i=0; i<10; i++){//Read values            num = scan.nextInt();            new_stack.push(num);        }        int new_k = scan.nextInt(); System.out.println(""+smallerK(new_stack, new_k));    }     public static int smallerK(Stack s, int k) {       ...
JAVA -Consider this program: public class Main { public static void main(String[] args) { String s1...
JAVA -Consider this program: public class Main { public static void main(String[] args) { String s1 = new String("hello"); String s2 = "hello"; String s3 = "hello";    System.out.println(s1 == s3); System.out.println(s1.equals(s3)); System.out.println(s2 == s3); } } When we run the program, the output is: false true true Explain why this is the output, using words and/or pictures.
JAVA What values are stored in variables a and b in the code below? public class...
JAVA What values are stored in variables a and b in the code below? public class StackQuestion { public static void main(String[] args) { Stack s = new Stack(); s.push(1); s.push(2); s.push(3); s.pop(); s.pop(); s.push(4); s.push(5); s.pop(); s.pop(); int a = s.pop(); s.push(6); int b = s.pop(); } } What numbers are stored in variable a and b when the code below executes? public class QueueQuestion { public static void main(String[] args) { Queue s = new Queue(); s.enqueue(1); s.enqueue(2);...
public class Programming { public static void main(String args[]) { System.out.println("I am learning how to program.");...
public class Programming { public static void main(String args[]) { System.out.println("I am learning how to program."); } } Compile this and execute this program then modify it to display I am learning how to program in Java. Change class name to Javaprogramming.java. compile and execute. Modify the Javaprogramming class so it prints two lines of output. Change name to Awesome. Add second output statement that displays That's awesome ! Save as awesome.java then compile and execute
//What is the output? import java.util.HashMap; public class AirportCodes {    public static void main (String[]...
//What is the output? import java.util.HashMap; public class AirportCodes {    public static void main (String[] args) {       HashMap<String, String> airportCode = new HashMap<String, String>();       airportCode.put("GRX", "Granada, Spain");       airportCode.put("ALB", "Albany, USA");       airportCode.put("IWJ", "Iwami, Japan");       System.out.print("ALB: ");       System.out.println(airportCode.get("ALB"));       airportCode.put("IWJ", "Ivalo, Finland");       System.out.print("IWJ: ");       System.out.println(airportCode.get("IWJ"));    } }
import java.util.Scanner; public class FindMinLength { public static int minLength(String[] array) { int minLength = array[0].length();...
import java.util.Scanner; public class FindMinLength { public static int minLength(String[] array) { int minLength = array[0].length(); for (int i = 0; i < array.length; i++) { if (array[i].length() < minLength) minLength = array[i].length(); } return minLength; } public static void main(String[] args) { Scanner in = new Scanner(System.in); String[] strings = new String[50]; for (int i = 0; i < strings.length; i++) { System.out.print("Enter string " + (i + 1) + ": "); strings[i] = in.nextLine(); } System.out.println("Length of smallest...
What will be the output of the given code? using System; class MyProgram { static void...
What will be the output of the given code? using System; class MyProgram { static void Main(string[] args) { try { int a, b; b = 0; a = 5 / b; Console.WriteLine("No exception will occur."); } catch (ArithmeticException e) { Console.WriteLine("Exception occurs."); } finally { Console.WriteLine("Program is executed."); } Console.ReadLine(); } } A Program is executed. B No exception will occur. C Exception occurs. Program is executed. D No exception will occur. Program is executed.
public class Mystery { public static String mystery(String str, int input) { String result = "";...
public class Mystery { public static String mystery(String str, int input) { String result = ""; for (int i = 0; i < str.length() - 1; i++) { if (input == 0) { str = ""; result = str; } if (input == -2) { result = str.substring(2, 4); } if (input == 1) { result = str.substring(0, 1); } if (input == 2) { result = str.substring(0, 2); } if (input == 3) { result = str.substring(2, 3); }...
Provide A UML for the Following CODE public class Employee{ public String strName, strSalary; public Employee(){...
Provide A UML for the Following CODE public class Employee{ public String strName, strSalary; public Employee(){    strName = " ";    strSalary = "$0";    } public Employee(String Name, String Salary){    strName = Name;    strSalary = Salary;    } public void setName(String Name){    strName = Name;    } public void setSalary(String Salary){    strSalary = Salary;    } public String getName(){    return strName;    } public String getSalary(){    return strSalary;    } public String...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT