JAVA QUESTION BANK 23-24
JAVA QUESTION BANK 23-24
5 List any four data types available in java with their storage size in bytes
int - 4 bytes char – 2 bytes
float – 4 bytes long – 8 bytes
double – 8 bytes Boolean – 1 bit
12 Wap to add 2 integers,2 string and 2 float values in a vector .Remove the
element specified by the user and display the list
13 Develop a program to find reverse of a number
14 Develop a program to declare class student having data members roll and
name .Derive class result having data members mark1,mark2 and method to
initialize and display the information for two objects
15 Wap to add 2 integers,2 string and 2 float values in a vector .Remove the
element specified by the user and display the list
Same as Q.12
16 List any four methods of string class and state the use of each
toUpperCase() and toLowerCase():Use: Converts a string to uppercase or
lowercase.
trim():Use: Removes leading and trailing white spaces from a string.
charAt(int index): Use: Returns the character at the specified index.
intern():Use: Returns a canonical representation of the string (from the
string pool).
length():Use: Returns the length (number of characters) of the string.
valueOf():Use: Converts other data types (e.g., int, double) to a string.
17 Wap to find out even numbers from 1 to 100 using for loop
Portability:
Java is portable because it facilitates you to carry the Java byte codes to any
platform. It doesn't require any implementation.
Java program can be moved from one computer to another, anywhere &
anytime, changes and upgrades in OS processors & system resources will not
force any change in JAVA program
22 compare method overloading and method overriding
1. Overloading:
o Two or more methods in one class have the same method name but
different parameters.
o It doesn’t apply polymorphism.
o It applies during compile time.
o Occurs between methods in the same class.
2. Overriding:
o Two or more methods with the same method name and parameters
o It applies polymorphism.
o It applies during run time.
o Occurs between superclass and subclass.
25 Define a class circle having data members pi and radius Initialize and display
values of data members also calculate area of circle and display it