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:
HashMapphoneBook = 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started