You are on page 1of 1

Java Programming (Theory)

Assignment 2
Q1. What will be the output of this program. Explain with the help of an example.

class Adder{
static int add(int a,int b){return a+b;}
static double add(int a,int b){return a+b;}
}
class TestOverloading3{
public static void main(String[] args){
System.out.println(Adder.add(11,11));//ambiguity
}}
Q2. Difference between method overloading and overriding with the help of an example.
Q3. Write a simple java program to check whether a number is palindrome or not.
Q4. Write a java program to print even and odd numbers from an array.
Q5. Write a java program to check whether two matrices are equal.
Q6. Java program to illustrate the concept of single inheritance (create a base class employee
and then create its subclasses).
Q7. Where is super keyword used in java? Explain it’s use in the previous example.
Q8. Create a class Box and use constructor overloading to calculate the volume of a box
object that takes
a. No initial dimensions
b. Length, breadth and width as its initial dimensions
c. Length (a cubic box is created)
Q9. Write simple programs to explain each of the following terms:
a. Inner class
b. Abstract class
c. Interface
Q10. Explain the use of various access modifiers using a single program.

You might also like