Java question bank
UNIT-I
What is the object oriented programming concepts in Java?
What are the data types in java and how to convert one data type to another?
What is constructor? Explain types of constructor and demonstrate calculate area using constructor.
Explain static, final and this keyword with suitable example.
What is object oriented programming?
Write a program in Java to generate the Fibonacci series taking into consideration the following constraints:
Create a class FIBO
Class FIBO should have a data member n, that will hold the number of terms to be displayed in the Fibonacci series.
Using the constructor of the class FIBO fill the value of n from the user during run time.
A member method named “series-generate” should be used to generate and display the Fibonacci series.
Write a program that multiplies two 3x3 matrices.
Describe different bitwise operators and their uses with proper example.
Define Java. Explain Java virtual Machine in brief.
Explain the features of Java and Java program structure.
Differentiate between method overloading and method overriding with example.
Define Java tokens. Explain various statements defined in Java with example.
What is object oriented programming language?
Explain features of Java program.
Explain constructor and its benefit using Java program.
What are modifiers? Explain static and final keyword using Java program.
What is the difference between array list and vector?
What do you mean by control flow? Write a java program to demonstrate the uses of control flow in Java.
Explain the following line used under Java program in detail:
public static void main(String args[])
Specify code written below is correct or not if yes what will be the output:
class A
{
static void staticMethod()
{
System.out.println(“Static Method”);
}
}
public class MainClass
{
public static void main(String []args)
{
A a = null;
a.staticMethod();
}
}
What do you mean by bytecode?
Explain various data types used in Java with examples.
Write the fundamental concept of oops with its diagram.
Define operators. How many types of operators are used in Java? Also explain the concepts of operators precedence.
What will be the output of the program?
class Bitwise
{
public static void main(String args[])
{
int x = 11 & 9;
int y = x^3;
System.out.println(y|12);
}
}
Write a program for inputting a string through keyboard and count the occurrence of character in the given string.
Explain the following in nutshell
Garbage collection
Security promises of Java.
Write the difference between constructor overloading and method overloading with proper example.
Explain public static void main (String args[])
What is object oriented programming and how it is different from procedure oriented programming?
Explain various features of Java.
Write a program to accept a number through command line argument and find factorial of a number.
Give the names of top class of all classes in Java and the top package which is the default package.
Java is not 100% pure object oriented language comment with suitable example.
Write a program for taking the input from user from 123 and do the following:
If the input is 1 call the default constructor
If the input is 2 call the constructor with two integer parameter
If the input is 3 call the constructor with string parameter
default constructor should print “hi this is default constructor”
integer parameter constructor should print the multiplication of both the integers
string parameter constructor should print that particular string message
Explain the concept of static and final with the help of example and also differentiate them in terms of memory updating.
How many types of parameter passing does Java support, name them?
Briefly explain the features of Java.
Explain the concept of static variable. Declare a class student that contain marks of 3 subjects and that class also contain two methods
void input()- that takes the value of the attributes of the class
void average()- that calculate the average marks of each student
Now if a class consists of 50 students then calculate the average marks of the class. average marks of each student will be added and then you have to find the class average using the concept of static variable.
Compare Java with C++.
UNIT-II
What is the use of super keyword in Java? Give suitable example.
Explain inheritance in Java with suitable example and how does inheritance perform with final keyword.
Explain differentiate between method overloading and method overriding with suitable example.
Explain what is error in programming? Explain exception handling and types in detail.
Compare the concept of interface and class in Java.
With the help of a Java program, explain the concept of package i.e. how packages can be created imported and used.
Implement using Java code your own exception class that can be used to prevent users from entering non alphabets in their names. Implement the code in such a manner that it becomes a user defined checked exception. Develop the program and explain the output.
Explain the use try catch throws and finally with proper example.
Write short notes on throw, throws and final keyword.
Explain the concept of abstract class and interface with an example.
Create a used user define exception class which throws exception when the user input marks greater than 100.
Define package. briefly explain how user defined package can be created with an example.
What is super keyword?
Explain difference between method overloading and method overriding. Give an example using Java program.
What is Interface in Java and why it is used? What are the benefits of interface? Give a suitable example of interface.
What is Exception in Java? Give a suitable example of user-defined exception using Java program.
What is immutable object? Can you write immutable object?
What will be the Boolean flag value to reach the finally block:
try
{
if(flag)
{
while(true)
{
}
}
else
{
System.exit(1);
}
}
finally
{
System.out.println(“In Finally”);
}
“In Java, a child has to satisfy the parent class constructor”. Justify this statement with program in Java.
Explain inbuilt and user defined checked and unchecked exception in Java and demonstrate them using a Java program.
Define abstract class.
What do you understand by an exception? Explain various types of exception with example. Also determine the difference between exception and error.
Explain different types of exception which handle during program handling. Write a program to reverse a string using exception.
Write a program to find the largest of three numbers using scanner class.
What will be the output of the program?
class Foo
{
public static void main(String args[])
{
try
{
return;
}
Finally
{
System.out.println(“Finaly”);
}
}
}
Discuss the various level of access protection available for packages and their implications.
Create try block that is likely to generate three types of exception and then incorporate necessary catch blocks to catch and handle them appropriately with proper explanation.
Define an exception called “No Match Exception” that is thrown when a string is not equal to “INDIA” write a program that uses this exception.
What do Super()?
Explain inheritance and the implementation of interface.
What is Interface? Differentiate interface and class.
Describe exception handling mechanism. Explain use of try catch and finally block.
Which class is the top most class of exception class hierarchy?
How super keyword is used to call superclass constructor? Explain it with suitable example.
What is interface? How it is different from abstract class? Write a source code for explaining the concept of interface.
Write a program using the concept of package. Make the given methods in one package named as pack 1 for
prime or not
Even or odd
and then import this package to write a code that uses this method to check a particular number on the above methods.
What is the use of super keyword in Java? Give suitable example.
Explain inheritance in Java with suitable example and how does inheritance perform with final keyword.
Explain differentiate between method overloading and overriding with suitable example.
Explain what is error in programming? Explain exception handling and types in detail.
Give two uses of super in Java.
Differentiate between abstract class and interface with example.
Create a user defined exception class which throws exception when the user input marks greater than 100 (takes marks for five subjects) otherwise print the total of marks.
Explain the concept of packages and show the access protection in packages.
ππ
ReplyDelete