Question: Using Java Q1. Create a class named Student with the fields: StudentName, StudentID, Age and MobileNo (data types are String and int). Q2 . Declare

Using Java

Q1. Create a class named Student with the fields: StudentName, StudentID, Age and MobileNo (data types are String and int).

Q2. Declare an empty and a parameterized Constructor for the above class(Student) and set the StudentName and StudentID.

Q3. Declare an Accessor method PrintStudent() in class Student to display the student details.

Q4. Declare a Mutator method UpdateAge() to increase the Age of a student by 2 years and print the updated Age. Q5. Open the codepad in Bluej and try the following statements. Write the results achieved.

a) Java Programming: + 123

b) 27 % 4

c) xyz + abc

Q6. Write a method ListAllStudent() from a university Collection.

Hint: Use for each loop

Q7. Draw Class Diagram and Object Diagram from the below given Details.

public class Car

{

private Sedan Model;

private Sedan Price;

}

Q8. Write a declaration of a private field named Department that can hold an ArrayList. The elements of the ArrayList are of type University. Write an assignment to the Department variable to create an appropriate ArrayList objects.

Q9. Create a class MapTester and use HashMap to implement a phonebook

given below:

HashMap phoneBook = new HashMap();
phoneBook.put("Homer Jay Simpson", "(531) 9392 4587"); phoneBook.put("Charles Montgomery Burns", "(531) 5432 1945"); phoneBook.put("Apu Nahasapeemapetilon", "(531) 4234 4418");
Q10. In the HashMap class, implement two methods : public void enterNumber(String name, String number) and 

public String lookupNumber(String name)

The methods should use the put and get methods of the HashMap class to implement their functionality.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!