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...
1. Define a class named Book that contains:  An int data field named pages that...
1. Define a class named Book that contains:  An int data field named pages that stores the number of pages in the book.  A String data field named title that represents the title of the book.  A constructor with parameters for initializing pages and title.  The getter and setter methods for all data fields.  A toString method that returns book information, including the book title and pages.  The equals method that returns true if...
Define the class HotelRoom. The class has the following private data members: the room number (an...
Define the class HotelRoom. The class has the following private data members: the room number (an integer) and daily rate (a double). Include a default constructor as well as a constructor with two parameters to initialize the room number and the room’s daily rate. The class should have get/set functions for all its private data members [20pts]. The constructors and the get/set functions must throw an invalid_argument exception if either one of the parameter values are negative. The exception handler...
Define the class HotelRoom. The class has the following private data members: the room number (an...
Define the class HotelRoom. The class has the following private data members: the room number (an integer) and daily rate (a double). Include a default constructor as well as a constructor with two parameters to initialize the room number and the room’s daily rate. The class should have get/set functions for all its private data members [20pts]. The constructors and the get/set functions must throw an invalid_argument exception if either one of the parameter values are negative. The exception handler...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT