0% found this document useful (0 votes)
24 views7 pages

Library Functions Worksheet

Uploaded by

palash.prabhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views7 pages

Library Functions Worksheet

Uploaded by

palash.prabhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

SMT.

RAMDEVI SOBHRAJ BAJAJ ARYA VIDYA MANDIR, JUHU


STD : X COMPUTER APPLICATIONS – LIBRARY FUNCTIONS

1. What do the following functions return given the declaration :


String a=”Brave” , b=”Hearts”;
i. System.out.println(a + b);
ii. System.out.println(a.length());
iii. System.out.println(b.charAt(2));
iv. System.out.println(a.equals(b));

2. What is the output of the following :


char a=’B’,b=’2’;
int c= a+b;
System.out.println(c);

3. If string x=”Tora” , y=”Tora”, z=”Flora” what is returned by the functions given below :
i. System.out.println(x+y+z);
ii. System.out.println(z.length());
iii. System.out.println(x.equals(y));
iv. System.out.println((x+y+z).toUpperCase());

4. What do the following functions return?


String x=”Guten” , y =”Morgan”;
1. System.out.println(x+” “+y);
2. System.out.println(x.equals(y));
3. System.out.println(y.indexOf(‘g’));
4. System.out.println(x.compareTo(y));

5. Given String p=”Welcome”, q=”Students”, r=p+” ”+q ;

What do the following functions return?

a) System.out.println(r);
b) System.out.println(r.substring(r.indexOf(‘u’)));
c) System.out.println(r.length());
d) System.out.println(r.substring(4,8));

6. What will be the output of the following code ?

char chars[ ] = {‘u’,’v’,’w’,’k’};


String str= new String(chars);
String s = new String(str);
System.out.println(str);
System.out.println(s);

AA Page 1 of 7
System.out.println(s.equals(str));
System.out.println(s==str);

7. If characters ‘B’ and ‘b’ have Unicode integer values 66 and 98 respectively, what will
be the output of the following ?

char p=’B’,q=’b’;
int r= p+q;
System.out.println(r);

8. String s=new String(“Moneybegetsmoney”);


Write the values of the following :
i. s.toUpperCase( );
ii. s.lastIndexOf(‘e’);
iii. s.charAt(5);
iv. char[ ] a=s.toCharArray();

9. 16. What is the value of Math.round(Math.abs(-19.70)) ?

10. Distinguish between Math.ceil(23.4) and Math.floor(23.4) ?

11. What do the following functions return ?


i. “cheers”.startsWith(“Hi”);
ii. “cheers”.indexOf(‘h’);
iii. “cheers”.lastIndexOf(‘e’);
iv. “cheers”.substring(1,3);

12. State the output produced by the code given below :


String rules = “Knowledge is less important than Imagination”;
String rules1,rules2;
rules1=rules.replace(“less”,”more”);
System.out.println(rules1);
rules2=rules1.replace(“Imagination”,”Knowledge”);
System.out.println(rules2);

13 . State the output produced by :


i. System.out.println(“Four :”+4+2));
ii. System.out.println(“Four :”+(2+2));

14. Give the output of


String x=”Computer”, y=”Application”;

i. System.out.println(x.substring(1,5));
ii. System.out.println(x.indexOf(x.charAt(4)));
iii. System.out.println(y+x.substring(5));
iv. System.out.println(x.equals(4));

15 . What do the following functions return: (I.C.S.E.2005)

String x=”hello”;
String y=”world”;

AA Page 2 of 7
i. System.out.println(x+y);
ii. System.out.println(x.length());
iii. System.out.println(x.charAt(3));
iv. System.out.println(x.equals(y));

16. What will be the output for the following program segment? I.C.S.E. 2006
String s= new String(“abc”);
System.out.println(s.toUpperCase());

17. Write a statement for each of the following: I.C.S.E. 2007


i) Store a number 275 as a String
ii) Convert the String to a numeric value.

18. What is the output of the following: I.C.S.E. 2007


i) System.out.println(“four:”+4+2);
System.out.println(“four:”+(2+2));

ii) String S1= “Hi”;


String S2= “Hi”;
String S3= “there”;
String S4= “HI”;
System.out.println(S1+”equals”+S2+ “→”+S1.equals(S2));
System.out.println(S1+”equals”+S3+ “→”+S1.equals(S3));
System.out.println(S1+”equals”+S4+ “→”+S1.equals(S4));
System.out.println(S1+”equalIgnoreCase”+S4+ “→”+S1.equalIgnoreCase(S4));

19. Give the output of the following: I.C.S.E. 2011


String n= “Computer Knowledge.”;
String m= “Computer Applications”;
System.out.println(n.substring(0,8).concat(m.substring(9)));
System.out.println(n.endsWith(“e”));

20. Write the output of the following: I.C.S.E. 2011


i. System.out.println(Character.isUpperCase(‘R’);
ii. System.out.println(Character.toUpperCase(‘j’);

21. What will be the output of the following code : I.C.S.E. 2011
double b=-15.6;
double a = Math.rint(Math.abs(b));
System.out.println(“a=”+a);

22. Write a statement each to perform the following task on a string: I.C.S.E. 2011
i. Find and display the position of the last space in a string s.
ii. Convert a number stored in a string variable x to double type.

23. Give the output of the following program segment: I.C.S.E. 2012
double x=2.9,y=2.5;
System.out.println(Math.min(Math.floor(x),y));
System.out.println(Math.max(Math.ceil(x),y));

AA Page 3 of 7
24. State the output of the following program segment I.C.S.E. 2012
String s= “Examination”;
int n=s.length();
System.out.println(s.startsWith(s.substring(5,n)));
System.out.println(s.charAt(2)==s.charAt(6));

25. State the method that: I.C.S.E. 2012


i) converts a string to a primitive float data type
ii) determines if the specified character is an uppercase character.

26. State the data type and values of a and b after the following segment is executed.
String s1= “Computer”, s2=”Applications”;
a=(s1.compareTo(s2));
b=(s1.equals(s2)); I.C.S.E. 2012

27. What will be the following code output? I.C.S.E. 2012


String s= “malayalam”;
System.out.println(s.indexOf(‘m’))’
System.out.println(s.lastIndexOf(‘m’));

28. State the values stored in the variables str1 and str2 I.C.S.E. 2013
String s1=”good”; String s2=”world matters”;
String str1=s2.substring(5).replace(‘t’,’n’);
String str2=s1.concat(str1);

29. What is the data type that the following library functions return? I.C.S.E. 2013
i) isWhitespace(char ch)
ii) Math.random( )

30. State the output of the following program segment: I.C.S.E.2 014
String str1=”great”;String str2=”minds”;
System.out.println(str1.substring(0,2).concat(str2.substring(1)));
System.out.println((“WH”+str1.substring(2).toUpperCase()));

31. What are the final values stored in variables x and y below? I.C.S.E. 2014
double a=-6.35;
double b=14.74;
double x= Math.abs(Math.ceil(a));
double y= Math.rint(Math.max(a,b));

32. What is the data type returned by the library functions: I.C.S.E. 2014
i) compareTo()
ii) equals()

33. State the value of characteristic and mantissa when the following code is executed.
I.C.S.E. 2014
String s=”4.3756”;
int n= s.indexOf(“.”);
int characteristic = Integer.parseInt(s.substring(0,n));
int mantissa = Integer.valueOf(s.substring(n+1));

AA Page 4 of 7
34. Study the method and answer the given questions. I.C.S.E. 2014

public void sampleMethod()


{
for(int i=0;i<3;i++)
{ for (int j=0;j<2; j++)
{ int number=(int)(Math.random()*10);
System.out.println(number);
}
}
}
i) How many times does the loop execute ?
ii) What is the range of possible values stored in the variable number ?

35. What will be the output when the following code segments are executed?
I.C.S.E. 2014

i) String s=”1001”;
int x=Integer.valueOf(s);
double y= Double.valueOf(s);
System.out.println(“x=”+x);
System.out.println(“y=”+y);

ii) System.out.println(“The king said \” Begin at the beginning!\” to me.”);

36. What is the value stored in variable res given below: I.C.S.E. 2015
double res =Math.pow(“345”.indexOf(‘5’,3);

37. State the data type and value of y after the following is executed: I.C.S.E. 2015
char x=’7’;
y=Character.isLetter(x);

38. State the output when the following program segment is executed:
I.C.S.E. 2015

String a=”Smartphone”,b=”Graphic Art”;


String h=a.substring(2,5);
String k=b.substring(8).toUpperCase();
System.out.println(k.equalsIgnoreCase(h));

39. Name the mathematical function which is used to find sine of an angle given
in radians. I.C.S.E. 2015

40. Name a string function used to find the prefix and suffix of a string.
I.C.S.E. 2015

41. Give the output of the following string functions: I.C.S.E. 2016
i) “MISSISSIPPI”.indexOf(‘S’) +“MISSISSIPPI”.lastIndexOf(‘I’);

AA Page 5 of 7
ii) “CABLE”.compareTo(“CADET”)

42. Give the output of the following Math functions: I.C.S.E. 2016
i) Math.ceil(4.2)
ii) Math.abs(-4)

43. Write down Java expression for: I.C.S.E. 2016


T= ÕA2+B2+C2

44. Write the return type of the following functions: I.C.S.E. 2016
i) isLetterOrDigit(char)
ii) replace(char, char)

45. String x[ ] ={“SAMSUNG”, “NOKIA”,SONY”,.MICROMAX”,”BLACKBERRY”};


Give the output of the following statements: I.C.S.E. 2017
i) System.out.println(x[1]);
ii) System.out.println(x[3].length());

46. State the data type and value of res after the following is executed? I.C.S.E. 2017
char ch=’t’;
res=Character.toUpperCase(ch);

47. Write the output for the following: I.C.S.E. 2017


String s=”Today is Test”;
System.out.println(s.indexOf(‘T’));
System.out.println(s.substring(0,7)+ “ “+”Holiday”);

48. What are the values stored in variables r1 and r2? I.C.S.E. 2017
i) double r1=Math.abs(Math.min(-2.83,-5.83));
ii) double r2=Math.sqrt(Math.floor(16.3));

49. Give the output of the following: I.C.S.E. 2017


String A=26”, B=”100”;
String D= A+B+”200”;
int x= Integer.parseInt(A);
int y=Integer.parseInt(B);
int d=x+y;
System.out.println(“Result 1 =”+D);
System.out.println(“Result 2 =”+d);

50. System.out.print(“BEST”); I.C.S.E. 2018


System.out.println(“OF LUCK”);
Choose the correct option for the output of the above statements:
(i) BEST OF LUCK
(ii) BEST
OF LUCK

51. Write the return data type of the following functions: I.C.S.E. 2018
i) endswith()
ii) log( )

AA Page 6 of 7
52. Give the ouput of the following: I.C.S.E. 2018
(i) Math.floor(-4.7)
(ii) Math.ceil(3.4) + Math.pow(2,3)

53.. Give the output of the following String functions: I.C.S.E. 2018
(i) “ACHIEVEMENT”.replace(‘E’,’A’)
(ii) “DEDICATE”.compareTo(“DEVOTE”)

54. Consider the following String array and give the output: [I.C.S.E 2018]
String arr[ ]={“DELHI”,”CHENNAI”, “MUMBAI”, LUCKNOW”, “JAIPUR”};

System.out.println(arr[0].length()>arr[3].length());
System.out.println(arr[4].substring(0,3));

55. Give the output of the following expressions : (MAR ‘ 08)


i. If x=-9.99, calculate Math.abs(x);
ii. If x=9.0 , calculate Math.sqrt(x);

56. If String x = “Computer” , y=”Applications”; (MAR ’08)


What do the following functions return for
i. System.out.println(x.substring(1,5));
ii. System.out.println(x.indexOf(x.charAt(4)));
iii. System.out.println(y+x.substring(5));
iv. System.out.println(x.equals(y));

57. Write an expression for : (a+b) n (MAR ’09)


√3 + b
58. Give the output produced by the statements given below :
i. System.out.println(Math.ceil(-28.35));
ii. System.out.println(Math.floor(144.99));
iii. System.out.println(Math.rint(38.96));
iv. System.out.println(Math.abs(3489.45));
v. System.out.println(Math.max(Math.min(15,25),5));
vi. System.out.println((int)(“dream”.charAt(2)));
vii. System.out.println(“Knowledge”.indexOf(‘e’));
viii. System.out.println(“PRESIDENT”.substring(3,4));
ix. System.out.println(“APTITUDE”.compareTo(“APTITUDE”));
x. System.out.println(“MISSISSIPPI”.lastIndexOf(‘s’));
xi. Distinguish between ceil() and floor().

59. int x=35; give the output of :


i. Math.ceil(Math.sqrt(x++));
ii. Math.floor(Math.sqrt(++x));

60. Distinguish between ceil() and floor().


10. Distinguish between compareTo() and equals().

AA Page 7 of 7

You might also like