THEORY-1 7.
Give the use, return type and argument type for the function
toLowerCase ( ) (for string) .
OUTPUT BASED QUESTI 8. Detect and correct the errors in the following code public
QUESTION-1. class remainder
(a) What is meant by private visibility of a method? {
(b) Identify the output for the following code snippet with logic: private int a,b;
remainder ( int x , y )
for(int I=2;I<15;I++) {
{ a = x % y;
while(I<6) }
continue; remainder rem = new remainder( );
[Link](I*+2); [Link]( a );
} }
(c) Consier the following: QUESTION- 3.
int a[]={2,5,8,5,3}; (i) Give the output
int i=2; class outt
a[i]+=(a[i+1]++)-(--a[i-1]); {
for(i=0;i<5;i++) public void av( )
[Link](a[i]); {
(d) Given String a = ”A” , b = ”a” , c = “malayalam”; What is the output? for(i=0;i<=10;i++)
(i) [Link] ([Link](b)); {
[Link] ([Link](b)); if(i==6)
(ii) [Link] ([Link](‘a’,2)); break;
[Link] ([Link]([Link](‘a’,3))); }
QUESTION-2. [Link](a);
1. Solve the following expressions }
i. int x = -2 , y ; }
y = x++ + x-- - x + x
ii. int c = -2 , d = 1; (ii) Define encapsulation,inheritance,polymorphism
c += d + ++c + d-- * c + d (iii) What is call by value and call by reference?
2. Write java expressions QUESTION 4.
2(𝑥 2 +𝑦 2 ) 1 𝑅2
(a) Name the keyword that
(i) (ii) 𝑓=√ − (i) Transfers the control to the beginning of the loop and
𝑥−𝑦 𝐿𝐶 4𝐶 2
3. Convert the following code skips the rest of the loop body.
i. To switch –case (ii) The variables whose single copy is made for all the
if ( s1 == ‘1’ ) objects of a class.
a = 1; (iii) The keyword that is used to distinguish between
else if ( s1 == ‘2’ ) instance variable and local variables.
a = 2; (b) Give the output of the following:
else if ( s1 == ‘3’ ) int x=10;
a = 3; int y=20;
ii. To do-while if((x<y)||(x=5)>10)
int n= 50; [Link](y);
for ( int i = 10; i >= 2; i = i – 2 ) else
n++; [Link](x);
(c) What will be the output of the following program segment?
4. Give output for the following String name[]={“Board”,”Examinations”};
for ( int x = 15; x > 1; x = x - 2) [Link](name[0].length());
{ [Link]([Link]);
if ( x > 10 )
(d) Find the output
[Link](++x);
else class Aa
[Link](--x); } {
5. Give output for the following void display()
String s = “application”; {
String st = “Program”; int a[]={2,5,8,5,3};
(i) [Link] ( int i=2;
([Link](st)).lastIndexOf(‘a’)) ); a[i]+=(a[i+1]++)-(--a[i-1]);
(ii) [Link] ( (s+” for(i=0;i<5;i++)
“+st).charAt([Link](st)) ); [Link](a[i]); } }
(iii) [Link]( (s+” “+st).length( ) ); (a) Differentiate between base and derived class.
− 𝑏+ √𝑏2 − 4𝑎𝑐
(iv) [Link]( (b) Write the java expressions for 𝑥 =
2𝑎
([Link](5,8)).concat([Link](3)) ); (c) Write function prototype that returns a Boolean value and
6. Write java statements for the following takes two characters as parameter.
(i) Assigns the square root of a number stored in (d) In Java various Math functions are defined in which class and
num to variable root. under which package.
(ii) Converts an integer value stored in val to (e) Write a single line statement using ternary operator to find
string and stores in s. the maximum of three numbers.
(iii) Replaces all occurrences of character ch by
chr in the string str.