Java BSCS M & E 2018-22
Java BSCS M & E 2018-22
1. Write a program that takes your full name as input and displays the abbreviations of the
first and middle names except the last name which is displayed as it is. For example, if
your name is Muhammad Haroon Mehmood, then the output should be M.H. Mehmood.
(10)
2. Create a class 'Student' with three data members which are name, age and roll. The
constructor of the class assigns name as of your own name, age as of your own age and roll
of as of your own roll no. It has two members with the same name 'setInfo'. First method
has two parameters for name and age and assigns the same whereas the second method
takes has three parameters which are assigned to name, age and roll respectively. Print the
name, age and roll no of 5 students.
Note: Use array of objects (10)
3. Write a program to print the names of students by creating a Student class. If no name is
passed while creating an object of Student class, then the name should be "Unknown",
otherwise the name should be equal to the String value (Your name) passed while creating
object of Student class.
Note: String value should be your name. (10)
4. A parent class named A has an integer data member 'm' and a method named 'printNum' to
print the value of 'm'. Its child class named B also has an integer data member 'n' and a
method named 'printNum' to print the value of 'n'. Make an object of the child class B and
use it to assign a value of 'n' to 'm'. Now call the method 'printNum' by this object.
(10)
5. Write a program that would print the information (name, year of joining, salary, address) of
three employees by creating a class named 'Employee'. The output should be as follows:
Name Year of joining Address
Robert 1994 64C- WallsStreat
Sam 2000 68D- WallsStreat
John 1999 26B- WallsStreat (10)