Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8674889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:49:03+00:00 2026-06-12T19:49:03+00:00

This is a homework question and im still a newbie to java. Write a

  • 0

This is a homework question and im still a newbie to java.
Write a code segment that computes the sum of all the values in marks.

This is my answer and it has compilation errors. Please help

class myArray{

    public static void main(String args []){

        int [] [] marks = {{1,2,3,4,5}, {6,7,8,9}, {10,11,12}};
        for(int i = 0; i<marks.length; i++){
            int sum = 0;
            for(int j = 0; j <marks[i].length; j++) {
                sum = sum + makrs[j][i];
            }
        }
        System.out.println(sum);

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:49:04+00:00Added an answer on June 12, 2026 at 7:49 pm

    There are two syntactical errors and one type.

    1. Move int sum =0; above for loop as you need it outside the loop to print the value
    2. Correct marks reading index from marks[j][i] to marks[i][j]
    3. Correct the typo in the same line as above (sum = sum + makrs[j][i];). You have typed makrs in place of marks

      int [] [] marks = {{1,2,3,4,5}, {6,7,8,9}, {10,11,12}};         
      
      int sum = 0;
      for(int i = 0; i<marks.length; i++){
          for(int j = 0; j <marks[i].length; j++){
              sum = sum + marks[i][j];
          }
      }
      System.out.println(sum);
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm stuck with this Java homework question: Write a new method, Refund, that simulates
I'm trying to solve this problem, its not a homework question, its just code
This is a homework question, and I'm asked to show that 8 element Binary
Ok so I've got this question for homework, I'm given that 'Host X' sends
Question. Write MIPS assembley code which is equivalent to the following Java code fragment.
I have a linked list question that stems from this homework prompt I am
This is a homework question, but I think there's something missing from it. It
This is a homework question. Question My attempt (the whole file): http://pastebin.com/TS6mByEj If you
I've got this as a homework question and dont know how I should go
This is the last question for my Oracle homework for the year and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.