Suggessio GRD
Suggessio GRD
Suggessio GRD
Question-5 marks
• What is encapsulation?How does a class accomplish data hiding? Give example. List out the differences between
Procedural and Object oriented programming.
• Write a program to access static variable and static method to explain static keyword property.
• What are the benefits of organizing classes into package?How can you create your own package and add classes to
that? Explain with help of an example
• What are the differences between method overloading and method overriding? What is dynamic binding and early
binding.Explain dynamic method dispatch with a suitable example.
• What is interface?Explain with help of an example how java gets befitted by using interface. Illustrate abstract class
with an example. Differentiate abstract class with interface.
• Describe a mechanism where both Inheritance and Polymorphism is used. Explain with an example.
• Explain the use of final keyword using a example program.
Question 1 marks
2. class A
{
int i;
void display()
{
System.out.println(i);
}
}
class B extends A
{
int j;
void display()
{
System.out.println(j);
}
}
class inheritance_demo
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
3. class average {
public static void main(String args[])
{
double num[] = {5.5, 10.1, 11, 12.8, 5.5};
double result;
result = 0;
for (int i = 0; i < 6; ++i)
result = result + num[i];
System.out.print(result/6);
}
}
4. class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * ++g);
}
}
5. class selection_statements
{
public static void main(String args[])
{
int var1 = 4;
int var2 = 6;
if ((var2 = 1) == var1)
System.out.print(var2);
else
System.out.print(++var2);
}
}
6. class A
{
public int i;
public int j;
A()
{
i = 1;
j = 2;
}
}
class B extends A
{
int a;
B()
{
super();
}
}
class super_use
{
public static void main(String args[])
{
B obj = new B();
System.out.println(obj.i + " " + obj.j) }}
8. class main_class
{
public static void main(String args[])
{
int x = 9;
if (x == 9)
{
int x = 15;
System.out.println(x);
}}
9. class box
{
int width;
int height;
int length;
}
class mainclass
{
public static void main(String args[])
{
box obj = new box();
obj.width = 10;
obj.height = 20;
obj.length = 10;
int y = obj.width * obj.height * obj.length;
System.out.print(y);
}
}
static
{System.out.print("2"); }
static
{ System.out.print("3"); }