7. In the code below, consider each marked statement. Is that statement legal (ie, the line will not generate a compiler error) or is it illegal? In making your determination about a particular line, assume all other declarations (variables and methods) and lines of code are OK and legal. That is, just consider that one line on its own in the context of all the other code. public class Student { Check Check Check protected String name; private int id; public Student (String n, int id) { name = n; // this.id = id; } public void enroll (int Course) { summarize (100.0); // } protected int nextUp() { return id+1; } System.out.println (name + " " + id); } public static void summarize (double d) { double x; x = d*d; enroll (int) x ); 11. public static void main (String [] args) { Student s1, s2, s3; int i; s2 = new Student (); // s1 = new Student ("Kelly", 23); s3 = new Student (s1); // // Check Check Check Check Check Check Check Check } } i = s3.nextUp (); } s1.enroll (1331); Student.summarize (200.0); public class Course { protected String instructor; protected int number; protected Student [] students; } s1.summarize (100.0); public Course (String i) { instructor = i; number = 0; students = new Student [100]; public void addStudent (Student s) { int i; students [number] = s; //_ // 11_ // // System.out.println ("Adding " + s); System.out.println("with name "+s.name); i = s.nextUp (); System.out.println (i+" is next up"); // // Check Check Check Check Check Check

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
icon
Related questions
Question
7. In the code below, consider each marked statement. Is that
statement legal (ie, the line will not generate a compiler error)
or is it illegal? In making your determination about a particular
line, assume all other declarations (variables and methods) and lines
of code are OK and legal. That is, just consider that one line on its
own in the context of all the other code.
public class Student {
Check
Check
Check
protected String name;
private int id;
public Student (String n, int id) {
name = n;
//
this.id = id;
}
public void enroll (int Course) {
summarize (100.0);
//
}
protected int nextUp() {
return id+1;
}
System.out.println (name + " " + id);
}
public static void summarize (double d) {
double x;
x = d*d;
enroll (int) x );
11.
public static void main (String [] args) {
Student s1, s2, s3;
int i;
s2 = new Student ();
//
s1 = new Student ("Kelly", 23);
s3 = new Student (s1);
//
//
Check
Check
Check
Check
Transcribed Image Text:7. In the code below, consider each marked statement. Is that statement legal (ie, the line will not generate a compiler error) or is it illegal? In making your determination about a particular line, assume all other declarations (variables and methods) and lines of code are OK and legal. That is, just consider that one line on its own in the context of all the other code. public class Student { Check Check Check protected String name; private int id; public Student (String n, int id) { name = n; // this.id = id; } public void enroll (int Course) { summarize (100.0); // } protected int nextUp() { return id+1; } System.out.println (name + " " + id); } public static void summarize (double d) { double x; x = d*d; enroll (int) x ); 11. public static void main (String [] args) { Student s1, s2, s3; int i; s2 = new Student (); // s1 = new Student ("Kelly", 23); s3 = new Student (s1); // // Check Check Check Check
Check
Check
Check
Check
}
}
i = s3.nextUp ();
}
s1.enroll (1331);
Student.summarize (200.0);
public class Course {
protected String instructor;
protected int number;
protected Student [] students;
}
s1.summarize (100.0);
public Course (String i) {
instructor = i;
number = 0;
students = new Student [100];
public void addStudent (Student s) {
int i;
students [number] = s;
//_
//
11_
//
//
System.out.println ("Adding " + s);
System.out.println("with name "+s.name);
i = s.nextUp ();
System.out.println (i+" is next up");
//
//
Check
Check
Check
Check
Check
Check
Transcribed Image Text:Check Check Check Check } } i = s3.nextUp (); } s1.enroll (1331); Student.summarize (200.0); public class Course { protected String instructor; protected int number; protected Student [] students; } s1.summarize (100.0); public Course (String i) { instructor = i; number = 0; students = new Student [100]; public void addStudent (Student s) { int i; students [number] = s; //_ // 11_ // // System.out.println ("Adding " + s); System.out.println("with name "+s.name); i = s.nextUp (); System.out.println (i+" is next up"); // // Check Check Check Check Check Check
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education