Trending ▼   ResFinder  

ICSE Board Exam 2017 : Commercial Applications

7 pages, 0 questions, 0 questions with responses, 0 total responses,    0    0
jaideep_singh_datta
Sacred Heart School (SHS), Moga
10
+Fave Message
 Home > jaideep_singh_datta >

Formatting page ...

SACRED HEART SCHOOL Moga, Punjab Department of Computer Science Class X-Assignment on Functions and Constructors 1. What is meant by constructor overloading 2. What are access specifiers 3. Can a program having a class declaration run without a constructor? Justify 4. How is pass by value different from pass by reference 5. What is the role of the keyword void in declaring functions 6. Differentiate between Method Prototype and Method Signature 7. Differentiate between Arguments and Parameters 8. Differentiate between Formal and Actual Parameters 9. Differentiate between pass by value and pass by reference 10. Differentiate between constructor function and Normal function 11. Why do we need static members? 12. Define the term this keyword 13. A class object is also known as ________ 14. Which keyword makes class members accessible outside the class in which they are declared? 15. A class object is also known as ________. 16. A member function having the same name as that of the class name is called _________ 17. A constructor has ___________ return type 18. A constructor is used when an ___________ is created 19. A constructor without any argument is known as ____________ 20. _____________ constructor creates objects by passing value to it 21. The ____________ refers to the current object 22. The constructor generated by a compiler is known as ______________ 23. Differentiate between the following statements a. Abc(5,7,9) b. Abc o=new abc(5,7,9); 24. What is the difference between Local variables and Instance Variables? 25. How does compiler resolve which function is to be called from overloaded function? 26. Read the given segment of program and answer the questions that follows: class customer { private long cust_id; String cust_Name; customer(long id, String n) SACRED HEART SCHOOL Moga, Punjab Department of Computer Science Class X-Assignment on Functions and Constructors { cust_id=id; cust_name=n; } public char funct() { S.o.pln(cust_id+ +cust_name); char chr= # ; return chr; }} a. Define the main method that invokes the constructor and the member functions of the class? b. Name the members of the class that can be accessed in the main method contained in the same class Customer. 27. Differentiate Call by Reference and Call by Value? 28. Define a class student describe as below: Data members/instance variable: Name, age, m1, m2, m3 (marks in 3 subjects), maximum, average. Member methods: Student() A parameterized constructor to initialize the data members. Void getdata() Void maxi() To accept the details of the student. To compute the average and maximum out of three marks. Void display() To display the name, age, marks in three subjects, maximum, average. Write a main method to create an object of the class and call the above methods. 29. Define a class called ARRAY having following members: Data Members: array A of 10 integers,avg Member Functions readArray() -Input 10 integers in array A. showArray() - display array elements sel_sort -arrange array A in Ascending order by using selection sort method findAvg() -find the average of second smallest and second largest element 30. Design a class to overload a function compare() as follows: void compare(int,int) to compare two integer values and print the SACRED HEART SCHOOL Moga, Punjab Department of Computer Science Class X-Assignment on Functions and Constructors greatest of the two integers. void compare(char,char) to compare the numeric value of two characters and print the character with higher numeric value void compare(String,String) to compare the length of the two strings and print the longer of the two 31. What does the following mean? Employee staff = new Employee ( ); 32. Write a statement to create an object named act of a class Action that invokes a parameterized constructor that accepts two bytes of values. 33. Read the following code and answer the questions that follows Class numbering { int n; void store(Numbering num) { num.n++; } public static void fun() { Numbering ob=new Numbering (); ob.n=100; // line 1 // line 2 ob.store(ob); // line 3 System.out.println(ob.n); } } 1. Explain the part labeled as line 1, line 2, line 3 of the program 2. State the output 34. Write a class with the name volume using function overloading that computers the volume of a cube, a sphere and a cuboid. Formula: volume of a cube (vc) = s * s * s Volume of a sphere (vs) = 4/3 * pi * r * r *r (where pi = 3.14 or 22/7) Volume of a cuboid (vcd) = l * b * h 35. In the program given below, state the name and the value of 1. Method argument or argument method 2. Class variables 3. Local variable 4. Instance variable SACRED HEART SCHOOL Moga, Punjab Department of Computer Science Class X-Assignment on Functions and Constructors Class shs { static int a=3; int y=2; public static void main(String ss[]) { shs s=new shs(); System.out.println(a); s.calledfunction(7); int a=9; System.out.println(a); } void calledfunction(int d) { System.out.println(d); Syste,.out.println(y); }} 36. Create a class with one integer instance variable. Initialize the variable using 1. Default constructor 2. Parameterized constructor 36. int power ( int x , int y ) { int f = 1 ; for ( int i = 1 ; i <= y ; i + + ) f*=i; return ( f ); } Answer the following : 1. What is the term given to the variables x and y ? 2. What is the significance of the type int used before the method name 3. Name the type of method shown above 4. In one line state that what the method shown above is computing power? 37. Consider the following code and answer the questions that follow: Class academic { int x,y; SACRED HEART SCHOOL Moga, Punjab Department of Computer Science Class X-Assignment on Functions and Constructors void access() { int a,b; academic st=new academic(); System.out.println( Object created ); } } 1. What is the object name of class academic? 2. Name the class variable used in the program? 3. Write the local variable used in the program? 4. Give the type of function used and its name? 38. Create a classSalaryCalculationthat is described as below: Class Name :SalaryCalculation Data members : name (String type data) basicPay, specialAlw, conveyanceAlw, gross, pf, netSalary, AnnualSal(All double type data) Member methods : (i) SalaryCalculation( ) - A constructor to assign name of employee (name), basic salary(basicPay) of your choice, accept all other data member values except conveyance and set conveyance allowance (conveyanceAlw)as 1000.00 (ii) void SalaryCal( ) - to calculate other allowances and salaries as given:specialAlw = 25% of basic salary.gross = basicPay + specialAlw + conveyanceAlw. netSalary = gross - pf.AnnualSal = 12 months netSalary. (iii) void display( ) - to print the name and other calculations with suitable headings. Write a program in Java to calculate all the details mentioned above and print them all. 39. Design a class to overload a function print ( ) as follows: (a) void print (int x, int y) to print the odd numbers between the x and y. (b)void print (char ch1, char ch2) to print all the consonants between the 2 characters ch1 & ch2. (c) void print (char ch, int n) to print the character ch, n number of times in the given format: Example: ch = $ and n = 4 Output: $ $ $ $ $$$ $$ SACRED HEART SCHOOL Moga, Punjab Department of Computer Science Class X-Assignment on Functions and Constructors $ 40. Write a Java program to input a sentence from the user in lowercase and capitalize the first and the last characters of every word in it. Sample Input : i love java for school. Sample Ouptut : I LovE JavA FoR SchooL Some of the data members and member functions are given below: Class name : Capitalize Data members/instance variables: sent : stores the sentence cap : to store the new sentence size : stores the length of the sentence Member functions: Capitalize() : default constructor void readsentence() : to accept the sentence void capfirstlast() : extract each word and capitalize the first and the last alphabet of the word and form a new sentence 'rev' using the changed words void display() : display the original sentence along with the new changed sentence. Specify the class Capitalize giving details of the constructor Capitalize (), void read sentence() ,void capfirstlast() and void display(). Define the main()function to create an object and call the function accordingly to enable the task. 41. Write a statement to create an object named act of a class Action that invokes a parameterized constructor that accepts two byte type value. 42. What is the return type of a constructor? What will not be the return type of a function, if it returns a value. 43. What type of data can be passed to a function by value? 44. Define a method convert(double) of long data type to convert the price of an article in decimal form. E.G 87.92 and return the amount in paise. SACRED HEART SCHOOL Moga, Punjab Department of Computer Science Class X-Assignment on Functions and Constructors 45. Answer the following question referring the code given below. public class xyz { inta,b; double c; String nam; xyz() { a=0; b=0; } xyz(int x, double d, String n) {} 1. Name the formal parameters. 2. List the global variables.

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

 

  Print intermediate debugging step

Show debugging info


 

 

© 2010 - 2025 ResPaper. Terms of ServiceContact Us Advertise with us

 

jaideep_singh_datta chat