ISC Board Important Question 2018 - Computer Science Theory Paper
Question and Answer
1. Differentiate between the keywords – “extends” and “implements”.
Ans. Differentiate between the keywords – “extends” and “implements”.
5. What is the condition for a sub class to explicitly call the constructor of it’s super class?
1. Differentiate between the keywords – “extends” and “implements”.
Ans. Differentiate between the keywords – “extends” and “implements”.
EXTENDS | IMPLEMENTS |
---|---|
|
|
2. What is the rule pertaining to Access Specifiers in Method Overriding?
Ans. The rule pertaining to Access Specifiers in Method Overriding is:
The access specifier of the overriding method in the child class cannot have an access specifier which is more restrictive than the method in the parent class.
The child class overriding method can either have an access specifier which is equal or less restrictive than that of the parent class method.
Remember that the chain of access specifier is as follows: private -> default -> protected -> public
3. How do you prevent a sub class from having access to a member of a super class?
To prevent a subclass from having access to a superclass member, we declare that member as private.
4. Are the constructors of the super class inherited automatically (implicitly) by the sub class?
No, when a class is inherited, all its members are inherited except the constructor and the members declared private.
In order to explicitly call the constructor of the super class from the sub class, we use the keyword super( ) which should be the first statement in the sub class constructor.
6. Write an equivalent ‘For Loop’ for the ‘While Loop’ given below:
public void sum (int n)
{
int s=0;
while(n>0)
{
s=s+n%10;
n/=10;
}
System.out.println(“Sum of digits = “+s);
}
Ans.
7. What will happen if the keyword ‘break’ is replaced by ‘continue’ in the below code?
int i=60;
while (true)
{
if (i <= 12 )
break;
i = i – 12;
}
System.out.println(“i = “+i);
Ans.
8. What will happen if the keyword ‘break’ is replaced by ‘continue’ in the below code?
int i=60;
while (true)
{
if (i <= 12 )
break;
i = i – 12;
}
System.out.println(“i = “+i);
Ans.
9. What is the output of this program?
class recursion
{
int func (int n)
{
int result;
if (n == 1)
return 1;
result = func (n - 1);
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.func(5));
}
}
Ans. 1
10. What is the output of this program?
class recursion
{
int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.fact(5));
}
}
Ans. 120
11. What is the output of this program?
class recursion
{
int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.fact(1));
}
}
Ans. 1
6. Write an equivalent ‘For Loop’ for the ‘While Loop’ given below:
public void sum (int n)
{
int s=0;
while(n>0)
{
s=s+n%10;
n/=10;
}
System.out.println(“Sum of digits = “+s);
}
Ans.
7. What will happen if the keyword ‘break’ is replaced by ‘continue’ in the below code?
int i=60;
while (true)
{
if (i <= 12 )
break;
i = i – 12;
}
System.out.println(“i = “+i);
Ans.
8. What will happen if the keyword ‘break’ is replaced by ‘continue’ in the below code?
int i=60;
while (true)
{
if (i <= 12 )
break;
i = i – 12;
}
System.out.println(“i = “+i);
Ans.
9. What is the output of this program?
class recursion
{
int func (int n)
{
int result;
if (n == 1)
return 1;
result = func (n - 1);
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.func(5));
}
}
Ans. 1
10. What is the output of this program?
class recursion
{
int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.fact(5));
}
}
Ans. 120
11. What is the output of this program?
class recursion
{
int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.fact(1));
}
}
Ans. 1
The ICSE board is one of the most popular boards in India and students who belong to the Icse board are very lucky. Because of the covid crisis, many students have been not concentrated on their studies, and Now they are worried about their exam then don't fear because Ziyyara is here for Helping You.
ReplyDeleteVisit On:- icse online tuition
Phone no - +91-9654271931