Question

In: Computer Science

Define a class named University with data members such as campus_name, courses_offered and no_of_faculty. Include appropriate...

Define a class named University with data members such as campus_name,
courses_offered and no_of_faculty. Include appropriate methods and illustrate
the following object oriented concepts.
i.
Polymorphism.
ii.
Static methods

Solutions

Expert Solution

Code in java

//creating university class
class University{
//initializing the attributes
String campus_name="null";
String course_offered="null";
int no_faculty=20;
//function used to check eligibility
public void checkeligibility(int no){
//function take one input from user which is number of faculty(no)
//checking if the university has minimum faculty number
if(no>=no_faculty)
//if not println
System.out.println("Eligible");
else
//else println
System.out.println("Not Eligible");
}
}
//creating another class which inherit the university class
class college extends University{
//initializing the static variable which can be accessd without creating a instance
static int seatcount=300;
//this method represent Polymorphism(Polymorphism uses methods from parent class to perform different tasks)
  
public void checkeligibility(int no){
//checking if the college has minimum faculty number
if(no==no_faculty)
//if not println
System.out.println("This college is Eligible");
else
//else println
System.out.println("This college is Not Eligible");
}
//this is an static method which can be accessed without creating the instance
static void seatsavailable(){
//function will print the seat count
System.out.println("seats availabale:-"+seatcount);
}
}
//main class
class Main{
public static void main(String[] args){
//creating instance of university class
University u1=new University();
//calling the function
u1.checkeligibility(22);
//creating instance of college class
college c1=new college();
//calling the method(Polymorphism)
c1.checkeligibility(22);
//calling the static method without creating the insatnce
college.seatsavailable();
}
}

Screenshots

Input\output


Related Solutions

Define a class named University with data members such as campus_name, courses_offered and no_of_faculty. Include appropriate...
Define a class named University with data members such as campus_name, courses_offered and no_of_faculty. Include appropriate methods and illustrate the following object oriented concepts. i. Polymorphism. ii. Static methods
In c++, define a class with the name BankAccount and the following members: Data Members: accountBalance:...
In c++, define a class with the name BankAccount and the following members: Data Members: accountBalance: balance held in the account interestRate: annual interest rate. accountID: unique 3 digit account number assigned to each BankAccount object. Use a static data member to generate this unique account number for each BankAccount count: A static data member to track the count of the number of BankAccount objects created. Member Functions void withdraw(double amount): function which withdraws an amount from accountBalance void deposit(double...
Develop a java program with a class named friend with data members like name, phno and...
Develop a java program with a class named friend with data members like name, phno and hobby. Use Parameterized constructor to create two friend objects and invoke checkhobby method which takes only one parameter, to find whether they have same hobby or different hobbies
In C++ Define a base class called Person. The class should have two data members to...
In C++ Define a base class called Person. The class should have two data members to hold the first name and last name of a person, both of type string. The Person class will have a default constructor to initialize both data members to empty strings, a constructor to accept two string parameters and use them to initialize the first and last name, and a copy constructor. Also include appropriate accessor and mutator member functions. Overload the operators == and...
Write a program in which define a templated class mySort with private data members as a...
Write a program in which define a templated class mySort with private data members as a counter and an array (and anything else if required). Public member functions should include constructor(s), sortAlgorithm() and mySwap() functions (add more functions if you need). Main sorting logic resides in sortAlgorithm() and mySwap() function should be called inside it. Test your program inside main with integer, float and character datatypes.
C++ Define a base class called Person. The class should have two data members to hold...
C++ Define a base class called Person. The class should have two data members to hold the first name and last name of a person, both of type string. The Person class will have a default constructor to initialize both data members to empty strings, a constructor to accept two string parameters and use them to initialize the first and last name, and a copy constructor. Also include appropriate accessor and mutator member functions. Overload the operators == and !=...
Write in C++ language. (Employee Record): Create a class named 'Staff' having the following members: Data...
Write in C++ language. (Employee Record): Create a class named 'Staff' having the following members: Data members - Id – Name - Phone number – Address - AgeIt also has a function named 'printSalary' which prints the salary of the staff.Two classes 'Employee' and 'Officer' inherits the 'Staff' class. The 'Employee' and 'Officer' classes have data members 'Top Skill' and 'department' respectively. Now, assign name, age, phone number, address and salary to an employee and a officer by making an...
Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a...
Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a doubleannual sales amount. Methods include a constructor that requires values for both data fields, as well as get and set methods for each of the data fields. Write an application named DemoSalesperson that declares an array of 10 Salesperson objects. Set each ID number to 9999 and each sales value to zero. Display the 10 Salesperson objects. public class DemoSalesperson { public static void...
java Define the Circle2D class that contains: • Two double data fields named x and y...
java Define the Circle2D class that contains: • Two double data fields named x and y that specify the center of the circle with get methods. A data field radius with a get method. • A data field radius with a get method. • A no-arg constructor that creates a default circle with (0, 0) for (x, y) and 1 for radius. • A constructor that creates a circle with the specified x, y, and radius. • A method getArea()...
Define the circle2d class that contains: Two double data fields named x and y that specify...
Define the circle2d class that contains: Two double data fields named x and y that specify the center of the circle with getter methods A data field radius with a getter method A no arg constructor that creates a default circle with 0,0 for x,y and 1 for the radius A constructor that creates a circle with the specified x,y of the the circle A method getArea() that returns the area of the circle A method Contains(Double x, Double y)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT