Wednesday, 21 November 2012

ASSIGNMENT



ASSIGNMENT

            Q1) a) What will be the contents of jTextarea1 after executing the following code:            1
     
jTextarea1.setText(“Kendriya\n Vidyalaya\t Guna”);
b)The following has some error(s).Rewrite the correct code underlining all the corrections made:                                                                                                       2
Int i, j=5;
i==j+5;
if(i=j)
{
jtextfield1.setText(“I and j are unequal”);
                        jtextfield1.setText(“I and j are not equal”);breaks;
      }
else
                        jtextfield1.setText(“I and j are equal”)

c) A School would like to go in for network of all the computers. Which topology would you recommend and why? (2)
d) What is communication channel? What choices do you have while choosing a communication channel for a network? (2)
e) What do you mean by network topology? Name most popular topologies. (2)
f) Navneet is using software, which has been downloaded from internet and is available for one month. After one month he has to pay license fee for further use. What software Navneet is using ? (1)
g) Akhil is transferring songs from his mobile to his friend’s mobile via Bluetooth connection. Name the network used by Akhil. (1)
h) Which of the following is not a characteristic of open source software? (1)
  • Its source code is available for modification
  • Its owned by a company or an individual
  • It can be downloaded by Internet
i) Which protocol is used for transfer of hyper text documents on the internet? (1)

Q2  a) Define inheritance with reference to object oriented programming.                  1
            b)  While working in net beans, Ranjeeta included a list box in the form. Now she wants
the list of her friend’s names to be displayed in it .Which property of list box control should she use to do this?                       1                                                                                                                
           c)What is the purpose of default clause in a switch statements ?                                1

           e) Write the two  properties of jtextfield?                                                                         1
       h)What is a list ? How is it different from combo box?                 
Q3  a. What is significance of Group By Clause in used in SELECT query ?                        2 
       b. What do you understand by Transaction COMMIT & ROLLBACK?                                  2
            c. What is constraint? Explain the difference between default and check constraints.        2
     d. You need to remove all the rows from the Sales_LIST table. You want to release the     1                                                                            storage spaces but do not want to remove the table structure. What is the solution to the problem?                                                                                     
. Predict the output:                                                                                                                   3
                                i.      Select round(29.21,1), round(32.76,1);
                             ii.      Select power(2,5);
                           iii.      SELECT DAYOFMONTH(‘2009-08-24’);
                           iv.      Select concat(‘catch a ’ ,concat( ‘falling’, ‘star’,null));
                              v.      SELECT MID(‘STUDENTS’,2,3);
Q 4  a) Create table Depart including constraints:                                                                                 2
         b)  Add one more column Email of datatype Varchar and size 30 to the table Depart           1
c)     Insert values in the table as S101, ‘Sales’, “delhi’, 120.                                                        1
d)      . Find the output : (5)
e)             (a) SELECT ROUND(20009.111,-2);
f)              (b) SELECT SQRT(81)+SQRT(49)+SQRT(121);
g)             (c) SELECT MID(‘VIDS Public School’ ,11,8), TRIM(LEADING ‘!’ FROM ‘!!!!!WEL COME!!!!!’); 
h)             (d) SELECT SUBSTR( RTRIM(‘INDIA IS GREAT  ‘),3,9);
i)                (e) SELECT CONCAT(UPPER (‘xiHum’), LOWER(’xiSc’), UPPER(SUBSTR(‘xiCom’,2,3)));


Q5). Write the html code to display the following controls :                                                             [3]
                     



Column Name
Dept ID
DeptName
DepartLOC
Distance
Key Type
Primary
Primary


Constraint


Unique
NotNULL
Datatype
Number
Varchar
Varchar
Number
Length
2
20
20
4
Q6.  (a)If database “Emplyoee” exists, which Mysql command helps you to starts working in that                       database?                                                                                                                        1         
(b) Mohit created a table in Mysql .later on he found that there should have been another        column in the table. Which commands should he use to add another column to the table?      1    (c) Remove the errors from query and rewriting it.                                                                  1
Select* from book where Price=NULL;

           (d) Which command is used in MySql to make the changes in database permanents?                                    1               
           (e)The itemno and cost column of a table “ITEM” are given below.                                        2
itemno
Cost
101
5000
102
NULL
103
4000
104
6000
105
NULL

           





Find the output of the following queries:
i)SELECT AVG(cost) FROM ITEMS;
ii) ELECT cost+100 FROM ITEM WHERE itemno>102;
iii) SELECT count(*) from items;

(g) A table “Animals“ in a database has 3 columns and 10 records. What is the degree and cardinality of this table?  What will happen if we add 2 more rows                           2
            (h) Differentiate DDL and DML commands with examples of each.                         2
            (i) What are multirow functions? 

Q7(a) What do you understand by primary key and candidate key.                                               2              (b) What is front-end?                                                                                                                         1
(c) Give societal impacts of e-business.                                                                                           2
 (d)  What are the benefits of E-Learning?                                                                                  1
 (e) Anu works for a Hotel. Sky warts to create controls on a form for the following function.    Choose appropriate controls from TextField, Label , RadioButton , CheckBox , List , ComboBox ,Button and write in the third column.                                                                      2
 S.No.
Controls  use to
Control
1
Select room type

2
Enter customers name

3
Enter arrival date

4
To book rook

Q8)           Consider the following tables ACTIVITY and COACH. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii)                        6
ACode
ActivityName
ParticipantsNum
PrizeMoney
ScheduleDate
1001
Relay 100x4
16
10000
23-Jan-2004
1002
High jump
10
12000
12-Dec-2003
1003
Shot Put
12
8000
14-Feb-2004
1005
Long Jump
12
9000
01-Jan-2004
1008
Discuss Throw
10
15000
19-Mar-2004

      Table: ACTIVITY
     
      Table: COACH
PCode
Name
ACode
1
Ahmad Hussain
1001
2
Ravinder
1008
3
Janila
1001
4
Naaz
1003

      (i)        To display the name of all activities with their Acodes in descending order.

(ii) To display sum of PrizeMoney for each of the Number of participants groupings (as shown in column ParticipantsNum 10,12,16)
     
(iii)     To display the coach’s name and ACodes in ascending order of ACode from the table COACH

(iv) To display the content of the GAMES table whose ScheduleDate earliar than 01/01/2004 in ascending order of ParticipantNum.
     
(V) SELECT COUNT(DISTINCT ParticipantsNum) FROM ACTIVITY;
                             
             (vi) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM ACTIVITY;
           
             (vii)   SELECT SUM(PrizeMoney) FROM ACTIVITY;
           
            (viii) SELECT DISTINCT ParticipantNum FROM COACH;
                                                                              
  Q9) Create a GUI application for a telecom company to calculate customer bill according to the rate charges given as below:
No of calls:
1-100   ------------ Rental /rs 500
101-200------------1 rs/call+ rental
201-300-------------1.20/call+rental
301 and above ------1.50/call+rental.
Give 10% discount to special customer

Q10) Create GUI application :
a) Find out sum of digits
b) Check whther a number is a palindrome or not
c) Check whther a number is even or not. If even . generate a factorial of the number. 
d) Check whther the given number is prime or not.

Q11)Predict the output of the following code fragments.
(a) float x =9;
float y = 5;
int z = (int) (x/y);
switch (z) {
case 1: x= x + 2;
case 2: x= x + 3;
default : x = x+1;
}System.out.println(“Value of x :” + x);

(b) int i,j,n;
n=0, i= 1;
do {
n++; i++;
} while(i<=5);

(c) int i =1, j = 0 , n = 0;
while (i<4) {
for (j=1; j<=i; j++) {
n +=1;
}i = i + 1;
} System.out.println(n);

Q12)Convert the following ‘while loop’ into its equivalent ‘for loop without altering the output of the program.
int x = 100, a = 30;
while ( x>= 10)
{
    System.out.println(”New Amount =”+(x + a));
    a++;
    x - = a;
}
Q13)Predict the output:
a)      String name=”TATA”;
int i=0;
While(i<name.length())
{
System.out.println(name.substring(I,i+1));
i++;
}
b)      int a=1;
int count=20;
do
{
a=a*count;
count=count-2;
} while(count<10);
system.out.print(a);

c)       Given a string object names salary having value as ‘55000” stored in it ., Obtain the output of the following:
JoptionPane.showMessageDialog(null,+salary.length()+Integer.parseInt(salary));

d)      String a=”abc”;
System.out.println(a+”abc”+”12”);

e)      Int a =5,b=10;
If(a>5)
If(b>5)
System.out.print(b);
Else
System.out.print(a);
System.out.print(“notvalid”);


Q14)A table named ITEM has the following contents:
+-------+--------------+----------+
| icode | iname | iprice |
+-------+--------------+----------+
| 101 | CHAIR | 1500.00 |
| 102 | DINING TABLE | 24000.00 |
+-------+--------------+----------+
Write the output that will be displayed by each SELECT statement as the SQL
statements given below are executed:
mysql> SELECT * FROM ITEM;
mysql> SET AUTOCOMMIT = 0;
mysql> INSERT INTO ITEM VALUES(103,'COFFEE TABLE',340);
mysql> SELECT * FROM ITEM;
mysql> ROLLBACK;
mysql> SELECT * FROM ITEM;
mysql> START TRANSACTION;
mysql> UPDATE ITEM SET IPRICE = IPRICE +200;
mysql> SAVEPOINT S1;
mysql> UPDATE ITEM SET IPRICE = IPRICE +400;
mysql> SELECT * FROM ITEM;
mysql> ROLLBACK TO S1;
mysql> SELECT * FROM ITEM;
Now verify the output by creating the table using MySQL and executing the above
statements.

Q15) Write the purpose of inserting Savepoints in a transaction.

Q16) Q4)  
(a) When the user select different seat type, then its price should be displayed in the Label.

(b) If the user enters an invalid no of seats i.e. less than I, then an error message should be displayed in the dialog box.
( c) When the user click at the Book Seats button , then total amount (calculated as no. of seats x price per seat) should be displayed along with payment method, next to the push button.

(c) Price per seat depend upon the seat type :

Stall 625/-
Circle 750/-
Upper Circle 850/-
Box 1000/-
 



Q) Tell one constraint which is not supported by table level.

In a database create the following tables with suitable constraints :

                           STUDENTS
+-----+--------------+-----+----+----+----------------------+----------------+
|AdmNo|Name          |Class| Sec| RNo| Address              | Phone          |
+-----+--------------+-----+----+----+----------------------+----------------+
|1271 |Utkarsh Madaan|  12 | C  |  1 | C-32,Punjabi Bagh    | 4356154        |
|1324 |Naresh Sharma |  10 | A  |  1 | 31,Mohan Nagar       | 435654         |
|1325 |Md. Yusuf     |  10 | A  |  2 | 12/21,Chand Nagar    | 145654         |
|1328 |Sumedha       |  10 | B  | 23 | 59,Moti Nagar        | 4135654        |
|1364 |Subya Akhtar  |  11 | B  | 13 | 12,Janak Puri        | NULL           |
|1434 |Varuna        |  12 | B  | 21 | 69,Rohini            | NULL           |
|1461 |David DSouza  |  11 | B  |  1 | D-34,Model Town      | 243554,98787665|
|2324 |Satinder Singh|  12 | C  |  1 | 1/2,Gulmohar Park    | 143654         |
|2328 |Peter Jones   |  10 | A  | 18 | 21/32B,Vishal Enclave| 24356154       |
|2371 |Mohini Mehta  |  11 | C  | 12 | 37,Raja Garden       | 435654,6765787 |
+-----+--------------+-----+----+----+----------------------+----------------+
                          SPORTS
+-----+-----------+----------+-----+
|AdmNo| Game      | CoachName|Grade|
+-----+-----------+----------+-----+
|1324 |Cricket    |Narendra  | A   |
|1364 |Volleball  |M.P.Singh | A   |
|1271 |Volleball  |M.P.Singh | B   |
|1434 |Basket Ball|I.Malhotra| B   |
|1461 |Cricket    |Narendra  | B   |
|2328 |Basket Ball|I.Malhotra| A   |
|2371 |Basket Ball|I.Malhotra| A   |
|1271 |Basket Ball|I.Malhotra| A   |
|1434 |Cricket    |Narendra  | A   |
|2328 |Cricket    |Narendra  | B   |
|1364 |Basket Ball|I.Malhotra| B   |
+-----+-----------+----------+-----+
a)
Based on these tables write SQL statements for the following queries:

i
Display the lowest and the highest classes from the table STUDENTS.




ii
Display the number of students in each class from the table STUDENTS.





iii
Display the number of students in class 10.





iv
Display details of the students of Cricket team





v
Display the Admission number, name, class, section, and roll number of the students whose grade in Sports table is 'A'.




vi
Display the name and phone number of the students of class 12 who play some game.




vii
Display the Number of students with each coach.





viii
Display the names and phone numbers of the students whose grade is 'A' and whose coach is Narendra.




b)
Identify the Foreign Keys (if any) of these tables. Justify your choices.





c)
Predict the output of each of the following SQL statements, verify the output by actually entering these statements:

i
SELECT class, sec, count(*) FROM students GROUP BY class, sec;



+-------+------+----------+




ii
SELECT Game, COUNT(*) FROM Sports GROUP BY Game;



+-------------+----------+

iii
SELECT game, name, address FROM students, Sports WHERE students.admno = sports.admno AND grade = 'A';


+-------------+----------------+------------------------+

iv
SELECT Game FROM students, Sports WHERE students.admno = sports.admno AND Students.AdmNo = 1434;


+-------------+
|+-------------+









Q16) Rewrite in switch
If(i==1)
System.out.println(“one”);
If(i==2)
If(i==3)
System.out.println(“two”);

Q17) output: for a=7,11
Int a=Integer.parseInt(jTextField1.getText());
If(a>10)
If(a>5)
System.out.println(“hurray”);
Else
System.out.println(“yippee”);