[go: up one dir, main page]

0% found this document useful (0 votes)
12 views10 pages

Chapter 3

This are the notes of chapter 3 of class 10th icse

Uploaded by

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

Chapter 3

This are the notes of chapter 3 of class 10th icse

Uploaded by

sureshyadav4612
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 10
» pifterentiate between formal parameter and 1 ctual parameter. write @ function prototype of the following ‘A. function PosChar which takes a string argument and a character argument and returns ‘an integer value. (ICSE 2016) 9 (id 1 what ae the two way of invoking functions? : (ICSE 2017) 1 write the prototype of function ‘check’ which takes 11 vir integer as an argument and returns a character. (ICSE 2018) 1.2. state aditference between call by value and call by "Teferenice. (ICSE 2019) 1.3. How are the following data types passed to a function ? + Primitive + Reference (ICSE 2005) 14. Explain the function of return statement in Java programming. (ICSE 2006) 15. The access modifier that gives least accessibility is : (2) private (b) public (6) protected (d) package. (ICSE 2022) 16. The keyword which indicates that the method returns no value : (@) public () static (©) void (@) abstract (ICSE 2022) 17. Write a function prototype of the following : (@) A function check which receives a character ch and an integer n and returns true or false. (b) A function abc that returns a double value and three parameters one of integer, one of float and cone of double data type. (©) A function ‘test’ that returns true or false and ‘takes an integer variable and a character variable as its argument. (b) A static method named ‘calculator’ that accepts ‘two short type variables as its arguments and , returns an integer value, (@) A function ‘divide’ that takes two double values as formal parameters and returns the quotient of double type (fA function ‘test’ that takes one character value and ‘one string value and does nat return any value. felon a ak | floats" takes three values as argument byte float and Short. Method argument a ‘sort’ that takes two values aS string array and an integer value and C088 Not return any value. (0) A method ‘convert that takes two objects of class _. Sent’ and returns a string value. A static method ‘CHARAT’ that takes two values imdunetion argument a character array and an integer value and returns a character value. 18. Give 4 met CUtDut of the following program segment (function) also write vihat ‘mathematical f ii y) K=x-y; else Yay~x + System.out.printino); if 40 and 18 are Passed to the function. (c) void func3 (char c) if System.out.printin((int) c); t if ‘w' is passed to c. (d) void func4(String a, String b) { if(a.compareTo (b)>0) System.out.printin(a); else System.out.printin(b); } if “AMIT" and “AMITABH” are passed to the function. (e) void func5(int n, int d) while(n > 1) ee Ee te values as argument byte feve and takes three float and Short, (ha Method argument a sti does not retu Wa Method ‘co ‘sent’ and ett QA static Met a8 function integer vaiy 8. Give the out ing program segment (function) acd oe ie ied “mathematical is ‘sort’ that takes two values @ ring array and an integer value and In any value. nvert’ that takes two objects of class ums a string value. hod ‘CHARAT? that takes two valued argument a character array and al 1@ and returns a character value. ) y/Stem.out pint G+"; if 10 is Passed to x, (b) He func2 (int x, int y) while (xlsy) sf if > y) X=X~y; else yx : pstom.out printing if 40 and 18 are Passed to the function. (C) void func3 (char c) uF System.out, Printin((int) c); } if ‘w' is passed to c. (d) void func4(String a, String b) { if(a.compareTo (b)>0) ‘System.out.printin(a); else System.out.printin(b); } if “AMIT" and “AMITABH” are Passed to the function. (e) void func&(int n, int d) while(n > 1) { if(n%d==0) a : { gyste™-0' nen /di I else d+ } } if 24 (p int func6(int a int b) ut.printin(d+ “"); and 2 are passed to the function. int an, 8: Ki if (@< D) an=k; while(an%s!=0) ant=k; return an; } if7 and 5 is passed as function argument. (g) boolean func7(int a, int b) boolean c=false; while(a>1 && b>1) return c; : if 27 arid 39 is passed as function argument. (h) int func&(int x, int y) return p; } if 5 and 3 are passed as function argument. 'Ss.length(); i+4) tempss.¢ =S.charAt(i) : return iene (i)stemp; } fl i *Programming» argumene "8" is passed as the function {) void f i { WtelO(String a, siring by 1 eHatHO > lengthy Syst : fe “™-out. printin(a.compareTolgnoreCase(b)); else at SEM out print compareTelgnoreCaselel } if PROGRES: S. ; unction arg and PROGRESSIVE is Passed as jument. 19. (a) in the given function prototype Public int add (intx, inty) \ lo © Name the different Components of the function Prototype numbered 1,2, 3,4. (b) State the difference betw and function signature. 20. (a) Which of the following return statements are invalid ? Give reason. (i) return (s, p); (ii) return (m — n); ii) return (s); (iv) return (m) — return (n); (b) State any two features of return statement. een function prototype 21. Debug the errors and rewrite the following function prototypes : (a) int add(a, b) (b) float product(a, int y) (c) String test(char [ 1, int ) (d) double operate(int a, float=4.5) (@) float sum(x, 7 a Jean test(al 1, char) pou compute tee double b) ic public char a (vo 1 input at a=2.5f, float b=a) ae atath(double a, double b) ere sall tha on Public i ie yw " van ty Public yh wie a main() function to call the given functions state's X of £125 tata; return a*a*a} } } 23. Why is the main() method in Java always declared as static ? 24. Identify the type of the following functions pure or impure. : (a) void max (int a, int b) int temp=a; a=b; b=temp; System. out. printin(ay""+-b); (b) void sort (int a (1, int n) { for (int i=0; i ate { int temp=a [j); aljl=a [j+1) a li+1] = temp; } } } a a “Read the given segments of program and a © questions that follow : Class Record { Public static void method (String x) { ~~eputer Applicati Ions (Ig; Ey pores ied Methods write down the statements 22 Wetic void Main() function ts cae seq they Jass X. 7 ofcl fue class X ons int a; int square( ) { return a*a; } static int cube ( ) { return a*a*a; } } 23. Why is the main() method whys th in Java aays ela 24. Identify the type of the fal ic a 1 following functions pure or (a) void max (int a, int b) { int temp=a; a=b; b=temp; ‘System.out.printin(a+*"+b); } (b) void sort (int a 0, int n) { for (int i= { for (int { if (a (> ale) { int temp=a UU alia fj +1) a [jl] = temp: } + } we } progr and a 25. Read the given seamen's ° the questions that flow (a) class Record 0 ing static void ethos ot ( public { _—_ 170 | (0); char a=x.charAt “ys char charAt (x.length0 Di intczat++-—Di yy a Dy system.out.printin(& ete , iter the + i in a, B64 (i) What value will be stores omputer” as the method gets executed method argument. | (i) Define the main method which calls method (). Itant (iii) Modify method ( ) so ‘that the resul returned by the function. (b) class My Class the above cis private short roll_n0; private long cand_code; private String cand_name; method of the class that displays d_code and roll_no, the gs “Rohan”, 2005123 } (i) Define a static the cand_name, can values being assigned and 20 respectively. (ii) Write a Java statement defined method in a non static-method. (c) class Mathematics { int a, b; public static int operate ( ) { intc=aH + Ha-a; intd=cH + b— return d; that calls the above -static method and a } () Write a single statement that call singles Is the meth un Be le sta void main() a il) What happens if an object ‘ob’ of y cla Mathematics directly invokes the variable ¢ and d in another static method as follows «in etn ob + 0b ii) The given function is a uncti Theshen fu n impure function, State (iv) What will be the final resultant values in a, b and d, if a and b ate initialized as § and 10 respectively? ee (@) double calculatetint x, double y) return x * y, } calculate(double x, double y) return wy; } oe @ state Taiven ft @ wt cau usi Static method. : -.y write the Java prototype for the function ca Wate to return a double result and accepts three float parameters. iy) Is the prototype void calculate (float a, float b) ‘ valid for the given functions. Give reason. (e) public static int calculate (int aC) function. Java statements to invoke the ing actual parameter in a a (int =O; i0) return true; else return false; } eth” 172 port ‘oid is the 4 (y Wie one statement that clined in another _norrs ; ‘on tot getvaluel) of the same ee ‘9 above functi Ci What wil be the ouPT ot tu? set func(20) and what v i” oroara follow! 26. Find the errors in the is and write the correct statemen' (a) static add (void) int a; b; a=2} and an ; system.out.printin(a+ +b) il dD (b) hablo static Void sentence (string x C { int y; y=x-length (); System.out.printin(y); } ' (c) double producttint p, 4) { } (d) public class Remainder { private int a, b; Remainder (int x, y) { aax%ys public static void main( ) Remainder rem=new Remainder(); © di class Name int squareroot (int a, int b) eum math.sart (a ~ b); public static void main () { eS Te (8, 15)); } (f) String method (String n) string x = name(); public static void main() String a= “India”; String x=-method(); }

You might also like