Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6. (15 pts) Find three errors in the following program. Circle the line number of the erroneous Java instructions. Explain the reason of the error

image text in transcribed
6. (15 pts) Find three errors in the following program. Circle the line number of the erroneous Java instructions. Explain the reason of the error right next to the erroneous line. You will not get credit if the reason is not correct. You will get a penalty if you mark a correct one as an error. 1 import java.util.ArrayList; 2 public class Bag { 3 private ArrayList data; private int id; 5 private static int serial_id; 6 7 public Bag() { data = new ArrayList(); id++; ) 9 10 public BagIterator getIterator() { 11 return new BagIterator(); } 12 public static BagIterator getAnotherIterator() { 13 return new BagIterator(); } 14 private class BagIterator { 15 private int count; private static int serial bag_num; 17 public Element next() { return data.get(count++); } 18 19 20 private static class Element ! private int value: private static int serial bag_num; + id); public int getValue() { System.out.println("ID of this bag is serial bag_num++; return value

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions