java consolidated
java consolidated
• "Explain the significance of access specifiers in Java and how they affect the
visibility and accessibility of class members."
• "Write a Java program to develop a Student class to represent information about
students. The class should include private member variables for student ID, and
GPA. Provide public accessor methods to retrieve information about students and
mutator methods to update their details. Ensure that access to the student's data is
restricted using appropriate access specifiers."
• "Explain static polymorphism with the help of constructor overloading. Write a
program to find the volume of sphere and hemisphere using the concept of
constructor overloading."
• "Suppose you have a Piggie Bank with an initial amount of $50 and you have to add
some more amount to it. Create a class 'AddAmount' with a data member named
'amount' with an initial value of $50. Now make two constructors of this class as
follows: 1 - without any parameter - no amount will be added to the Piggie Bank 2-
having a parameter which is the amount that will be added to the Piggie Bank Create
an object of the 'AddAmount' class and display the final amount in the Piggie Bank.
Also comment if the class 'AddAmount' demonstrates constructor overloading.
Justify your answer."
• "Can a class have multiple methods with same name but different parameters?
Justify with the help of an example."
• "Write the difference between procedural and object-oriented programming."
• "Explain the following principles of object-oriented programming:. 1. Object 2.
Class 3. Inheritance 4. Polymorphism 5. Encapsulation"
2. Java Programming
• "Write a java program to add 2 time quantities. Each time quantity should be
accepted as an object of the class time that has 3 components of time (hh,mm,ss).
Define a method add () that accepts the 2 objects as arguments and returns the
total duration in hh:mm:ss format."
• "WAP to count the frequency of occurrence of a given character in a given line of
text."
• "List wrapper classes and write a program to use them."
• "Write a countDown(int number) method in Java using Recursion which prints
countdown till zero to console, like count(3) should print 3 2 1 0."
• "WAP to display use of nested if else loop to show grade of student using following
conditions: 1. Percentage >75, then print Distinction 2. Percentage >=60 and <75,
then print First Class 3. Percentage >=40 and <60, print Second Class 4. Percentage
<40 then print Fail"
• "Write a java program to accept a number from command line and check if it is an
Armstrong number or not."
• "Create a user-defined package named calculator that contains a class called
BasicMaths. Inside this class, define methods for basic mathematical operations
such as addition and multiplication. Write a program that imports this package and
demonstrates the usage of these methods."
• "Write a Java program to create a registration form. Take a login ID and password
from the user and display it on the third text field which appears only upon clicking
the "OK" button. Clear both text fields on clicking the "RESET" button."
• "Write a program to design a form using Swing components. The form should
include one text field, one button and one combobox control with items- Cricket,
Football, and Hockey. Display the currently selected item of combobox in text field
when button with caption 'Submit' is pressed."
3. Memory Management
5. Exception Handling
• "State the use of try-catch and finally block in exception handling. Also, write a java
program illustrating how to handle ArrayIndexOutOfBoundsException using try-
catch block."
• "Explain the purpose of the 'throw' keyword in Java. Also, write a Java program to
create and throw a user-defined exception named "Marks OutOfBoundsException"
if the entered marks of the subject are greater than 100 or less than 0."
6. Multithreading
• "Draw labelled diagram of thread life cycle. Also, write a multithreaded program to
display /*/*/*/*/*/* using 2 child threads here one thread is responsible to print '*'
and other thread is responsible to print '/'. (Use Thread class for the
implementation)"
• "Define thread. List different approaches to create thread. Also, write a
multithreaded program in java to print table of Five, Seven and Thirteen using
Multithreading (Use Thread class for the implementation)"