23.4k views
4 votes
Solve using java language

Q1. Create a University System which has the following classes: Class Course which has the following: - Instance variables: Course name, Course no - Constructor that initializes the instance variables

User Bobwise
by
8.2k points

1 Answer

2 votes

Final answer:

To solve the requested problem, create a Java class named Course with private instance variables for the course name and number, and a constructor to initialize these variables. Additional methods like getters and setters can be added to access these variables.

Step-by-step explanation:

Java Class for a University Course System

To create a class named Course in Java for a university system, you need to define instance variables such as courseName and courseNo, and also include a constructor to initialize these variables. The following Java code snippet illustrates how to accomplish this:

public class Course {
private String courseName;
private int courseNo;

public Course(String courseName, int courseNo) {
this.courseName = courseName;
this.courseNo = courseNo;
}

// Getters and setters for courseName and courseNo can be added here
}

The constructor Course takes the name of the course and its number as parameters and initializes the instance variables accordingly. This is a typical approach when designing an object-oriented system in Java.

User Rohit Khanna
by
8.0k points