KENDRIYA VIDYALAYA ALIGANJ SHIFT-II HOLIDAY HOMEWORK 18-19 CLASS-XII INFORMATICS PRACTICES 1. Arrange the following data types in increasing order of their size : byte, int, float, double, char, boolean. What will be the value of jtextfield1 and jtextfield after executing the following code : int t=,x=1; t=(3*x++)/3; jtextfield1.settext( +t); jtextfield.settext( +x); 3. Rewrite the following code using while loop. for(int i=1;i<=1;i++) { JOptionPane.showMessageDialog(this,i); } 4. What will be values of a and b outside loop after execution of the following code: int a=1, b=; for(a=;a<=4;++a) { b=a++; --b; } 5. ABC School uses the following interface built in java to check the eligibility of a student for a particular stream from science, commerce and humanities. The user first enters the total percentage and selects the desired stream by selecting the appropriate option button. An additional 5% is marks is given to students of NCC.
Write Java Code for the following a) On the Action event of the close button the application gets closed. b) On the Action event of the clear button all the text fields and the check boxes get cleared. c) On Action event of the button Calc Percentage Net percentage of the student is calculated and displayed in the appropriate text filed. Net percentage is same as that of the actual percentage if the student doesn t opt for NCC, otherwise 5% is added to actual percentage. On Action Event of the button Result, the application checks the eligibility of the students. And display appropriate result (i.e. Eligible for a subject or Not Eligible for a subject) in the respective text field. Minimum percentage for science is 7, for commerce is 6 and for humanities is 4. 6. Find the errors from the following code segment and rewrite the corrected code underlining the correction made. int x,y; z = x + y; for(;i<=1;i++) { Display z; z=z+1 ] 7. Define the following terms- (1) Tuple (ii) Attribute (iii) Primary key (iv) JAVA Byte Code
8. What will be the output of following code? (i) SELECT POW(3,) ; (ii) SELECT SUBSTR( INFORMATICS PRACTICES,6,3); (iii) SELECT ROUND(39.7456,) ; (iv) SELECT TRUNCATE(39.7456,) ; (v) SELECT INSTR( INFORMATICS PRACTICES, MAT ); (vi) SELECT LEFT( INFORMATICS PRACTICES,6); 9. The name column of a table "EMPLOYEE" is given below: name Rozer Robert Scott Albert Ricky Glenn Allen Stuart Based on this information, find the output of the following queries: a) SELECT name FROM employee WHERE name like "_l%"; b) SELECT name FROM employee WHERE name not like "%t"; 1. Given below is a Table: Customer
i) Write SQL command to remove primary key from the table. ii) Write query to change width of column city to char long with varchar data type. 11. Write the Degree and Cardinality of the table Sports given below : Table: Sports GCod e GameName Number PrizeMoney ScheduleDate 11 Carom Board 5 3 Jan. 4 1 Badminton 1 1 Dec. 3 13 Table Tennis 4 8 14 Feb. 4 15 Chess 9 1 Jan. 4 18 Lawn Tennis 4 5 19 Mar. 4 1. Answer the question based on the table given below: TABLE : Employee Column Name Data Type Size Constraint Emp_No NUMBER 4 PRIMARY KEY EName VARCHAR Not Null Basic NUMBER 7 Basic is greater than Department VARCHAR 15 Not Null Gender VARCHAR 1 (i) Write the SQL command to create the above table with constraints. (ii) Insert a record with relevant information, in the table Employee (iii) Display all the records of the table Employee. (iv) Delete the Employee Whose Emp_No is 11. (v) Change the Department of Employee to Computer Whose Emp_No. is 1. (vi) Add one column email of data type VARCHAR and size 3 to the table Employee. (vii) Drop the table Employee.
13. Write SQL commands for (a) to ( f) and write output for (g) on the basis of EMP relation given below. Table : EMP EMPN ENA ME JOB MG R HIREDATE SAL COM M DEPT NO 7839 REA MANAGER 67 1-DEC-98 5 NUL 1 L 134 PREM CLERK 87 11-FEB-77 1 15 6754 SITA MANAGER 89 1-MAR-99 1 1 6574 GITA SALESMA 98 11-JUN-99 9 NUL 3 N L 9876 HONE CLERK 65 1-JUN- 1 8 Y 8976 REEM A SALESMA N 91 1-SEP-88 6 1 3 (a) List the details of those employees whose salary is more than 9. (b) Display data of all employees in descending order of their salary. (c) Display Ename, Job and Sal of all employees other than manager. (d) Display Ename, Hiredate and Comm of those employees who are not getting commission (i.e. COMM). (g) Find the output of the following : 1. SELECT DISTINCT JOB FROM EMP;. SELECT ENAME,SAL+COMM TOTAL SALARY FROM EMP WHERE COMM IS NOT NULL; 3. SELECT ENAME, SAL FROM EMP WHERE DEPTNO=1; 4. SELECT ENAME, JOB FROM EMP WHERE DEPTNO NOT IN (,3); 14. Create a Java Desktop Application to convert a given temperature Fahrenheit to Celsius and Vice Versa using switch case statement. Hints : C=5/9 * (F-3) and F=1.8*(C+3) Using a jbutton s click event handler, display the corresponding temperature value in a jtextfield control. Implement the following settings for IDE :
(i) On the Action event of the Clear button the text fields and radio buttons get clear. (ii) On the Action event of the Exit button the application gets closed. (iii) On the Action event of the button Convert the temperature is converted as per user s choice. 15. Write a java code to calculate and display the factorial of an integer stored in variable num. 16. Find the errors from the following code segment and rewrite the corrected code underlining the correction made. int a,b; c = a + b; for(;i<=5;i++) { ] Display c; c=c+1
17. Given below is a Table: Customer i) Write SQL command to remove primary key from the table. ii) Write query to change width of column city to char long with varchar data type. Write the Degree and Cardinality of the table Sports given below : Table: Sports GCod e GameName Number PrizeMoney ScheduleDate 11 Carom Board 5 3 Jan. 4 1 Badminton 1 1 Dec. 3 13 Table Tennis 4 8 14 Feb. 4 15 Chess 9 1 Jan. 4 18 Lawn Tennis 4 5 19 Mar. 4
18. Answer the question based on the table given below: TABLE : Student Column Name Data Type Size Constraint (i) (ii) (iii) Write the SQL command to create the above table with constraints. Insert a record with relevant information, in the table student Display all the records of the table Student. (iv) Delete the Student Whose Roll no is 1. (v) Change the Stream of Student to Computer Whose Roll no. is 536. (vi) (vii) Roll_No INTEGER PRIMARY KEY Name VARCHAR Not Null Stipend INTEGER Stipend is greater than Stream VARCHAR 15 Not Null Grade VARCHAR 1 View structure of the table created by you. Drop the column Grade from the table Student. 19. Write SQL commands for (a) to ( f) and write output for (g) on the basis of EMP relation given below. TABLE : EMP EMPN ENA ME JOB MG R HIREDATE SAL COM M DE PT NO 1 7839 REA MANAGER 67 1-DEC-98 5 NUL L 134 PREM CLERK 87 11-FEB-77 1 15 6754 SITA MANAGER 89 1-MAR-99 1 1 6574 GITA SALESMA 98 11-JUN-99 9 NUL 3 N L
9876 HONE Y 8976 REEM A CLERK 65 1-JUN- 1 8 SALESMA 91 1-SEP-88 6 1 3 N (a) List the details of those employees whose salary is more than 9. (b) Display data of all employees in descending order of their salary. (c) Display Ename, Job and Sal of all employees other than manager. (d) Display Ename, Hiredate and Comm of those employees who are not getting commission (i.e. COMM).. Find the output of the following : 1. SELECT DISTINCT JOB FROM EMP;. SELECT ENAME,SAL+COMM TOTAL SALARY FROM EMP WHERE COMM IS NOT NULL; 3. SELECT ENAME, SAL FROM EMP WHERE DEPTNO=1; 4. SELECT ENAME, JOB FROM EMP WHERE DEPTNO NOT IN (,3);