Kadi Sarva Vishwavidhyalaya: LDRP Institute of Technology and Research
Kadi Sarva Vishwavidhyalaya: LDRP Institute of Technology and Research
Kadi Sarva Vishwavidhyalaya: LDRP Institute of Technology and Research
Page 1 of 4
Q. II Find out error(s) if any in the following code and correct it.
1. class DemoPaper { [2]
public static void main(String ar[]) {
int a = 10;
{
int a = 20;
System.out.println(a);
}
System.out.println(a);
}
2. interface int1 { [3]
int a;
void put();
}
class myClass implements int1 {
void put() {
System.out.println(“Method Called”);
}
class DemoPaper {
public static void main(String ar[]) {
int1 c1 = new int1();
c1.put();
}
}
3. class gp { [2]
gp() {
System.out.println("Default - GP");
}
gp(int x) {
System.out.println("Parameterised - GP");
}
}
class p extends gp {
p() {
System.out.println("Default - P");
}
p(int x) {
System.out.println("Parameterised - P");
}
}
class child extends p {
child() {
Page 2 of 4
super(10);
System.out.println("Default - child");
}
child(int x) {
System.out.println("Parameterised - child");
}
}
class PaperDemo {
public static void main(String ar[]) {
child c = new child();
}
}
Q. III [A] Fill in the blanks such that program will generate expected [7]
output.
1. class FiboPaper {
public static void main(String args[]) {
int no = Integer.parseInt(args[0]);
_________ . fibo(__ ,__ ,no);
}
_______ void fibo(int f1, int f2, int no) {
int f3;
if(no==0) {
return;
}
f3 = f1 + f2;
System.out._________(f1 + " ");
fibo(___ ,____ ,____);
}
}
Expected Output:
3 5 8 13 21
OR
Page 3 of 4
_______ void peli(int no, int original) {
if(no==0) {
if(sum==original)
b = true;
else
b = false;
return;
}
int rem = no%10;
sum = sum*10 + rem;
peli(________ , original);
}
}
Expected Output:
If we enter no : 121, Output will be “Palindrom”
If we enter no : 123, Output will be “Not Palindrom”
Page 4 of 4