1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Luba_88 [7]
4 years ago
14

A teacher wants to create a list of students in her class. Using the existing Student class in this exercise. Create a static Ar

rayList called classList that adds a student to the classList whenever a new Student is created. In the constructor, you will have to add that Student to the ArrayList.

Computers and Technology
1 answer:
aleksandr82 [10.1K]4 years ago
4 0

Answer:

Check the explanation

Explanation:

CODE:-

import java.util.ArrayList;

class Student

{

  private String name;

  private int grade;

  private static ArrayList<Student> classList = new ArrayList<Student>();

 

  public Student(String name, int grade)

  {

      this.name = name;

      this.grade = grade;

      classList.add(this);

  }

 

  public String getName()

  {

      return this.name;

  }

 

  /*Don't change the code in this method!

  This method will print out all the Student names in the classList Array

  */

  public static String printClassList()

  {

      String names = "";

      for(Student name: classList)

      {

          names+= name.getName() + "\n";

      }

      return "Student Class List:\n" + names;

  }

}

public class ClassListTester

{

  public static void main(String[] args)

  {

      //You don't need to change anything here, but feel free to add more Students!

      Student alan = new Student("Alan", 11);

      Student kevin = new Student("Kevin", 10);

      Student annie = new Student("Annie", 12);

      Student smith = new Student("Smith", 11);

      Student kane = new Student("Kane", 10);

      Student virat = new Student("Virat", 12);

      Student abd = new Student("ABD", 12);

      Student root = new Student("Root", 12);

      System.out.println(Student.printClassList());

  }

}

Kindly check the attached image below.

You might be interested in
1. Why isn't solar energy usually the only power source for a region?
ale4655 [162]
1. Every region doesnt get the same amount of sunlight as the rest due to whether or location an example would be that a region with alot of rain could have clouds that wouldnt let the solar panels to absorb as much sunlight as a more dry and sunny place 
2 wind farms can be used to store energy for a power outage and a way to lower the cost of electricity to a farmer 
3 using hydro energy requires people to build a dam that pours the water over a mill that rotates and stores energy from it 
4 a type of waste created by nuclear power plants would be daily uses that have radiation such as plastic containers ,gloves , disposable overalls, boots or just plain radioactive waste.
5 would be the total mass of organisms in a given area or volume 
6 is a process to further limit carbon dioxide emissions from burning coal
7 is basically the means to tap into energy savings that over time become an asset 
8 turning down the water heater thermostat and turning off lights when not in use can save energy 
9 smart grids use timing grid to determine how long you use electricity for and for how much you used
6 0
3 years ago
Read 2 more answers
How do graphic designers showcase their work?
Luda [366]

They showcase it digitally since their work is done on computers.

6 0
4 years ago
Read 2 more answers
Quiz
Dmitrij [34]

Answer: False

Explanation: It is sent to committee then senate.

4 0
3 years ago
Given an array of integers check if it is possible to partition the array into some number of subsequences of length k each, suc
allochka39001 [22]

Answer:

Explanation:

Using Python as our programming language

code:

def partitionArray(A,k):

flag=0

if not A and k == 1:

return "Yes"

if k > len(A) or len(A)%len(A):

return "No"

flag+=1

cnt = {i:A.count(i) for i in A}

if len(A)//k < max(cnt.values()):

return "No"

flag+=1

if(flag==0):

return "Yes"

k=int(input("k= "))

n=int(input("n= "))

print("A= ")

A=list(map(int,input().split()))[:n]

print(partitionArray(A,k))

Code Screenshot:-

3 0
3 years ago
Who invented the first antivirus software and when was it written?
Bad White [126]

Answer:

The answer to this question can be given as:

The first antivirus was written in 1987 by the German security expert Bernd and the name of the antivirus is Vienna Virus.  

Explanation:  

Antivirus: It is a software or anti-malware software that is used for providing security. It is a tool that runs on various digital devices and searches for files that should not be on your computer. If the file is found then It defends the computer from incoming threats and seeks-out, stops and alerts of viable threats from the system so the computer works properly. So, the first antivirus was developed in 1987 by German security expert Bernd.

7 0
3 years ago
Other questions:
  • Ann wants to create a bookmark. She should
    9·2 answers
  • Do yall play games..............................................................................................................
    8·2 answers
  • What does the word complacency mean ?
    14·2 answers
  • Which device prints large, three-dimensional high-quality color graphics?
    15·1 answer
  • What’s the most popular operating system
    9·2 answers
  • Why should programmers use a Post Mortem Review?
    15·1 answer
  • Which of the following would be an appropriate use of a check box control?
    15·1 answer
  • Lan is working on a project report that will go through multiple rounds of
    10·1 answer
  • 9. Which of the following commands is executed with the shortcut 'Ctrl+Z'?
    11·1 answer
  • Jennifer has written a short story for children. What should be her last step before she submits the story for publication?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!