|
|
|
2015 Java Programming
|
|
|
2.
|
(a)
|
Write the values of t after the
execution of the following code:
int t;
int s;
s=6;
t = (8 * s++) % 7 ;
|
1
|
|
|
Ans.
|
6
|
|
|
|
(c)
|
In a SWITCH statement, what is the
purpose of BREAK statements?
|
1
|
|
|
Ans.
|
A BREAK statement causes control to
exit the SWITCH statement.
|
|
|
|
(e)
|
Write Java Code to assign the value 70
to variable y. Then decrease the value of y by 5 and store it in variable z.
|
2
|
|
|
Ans.
|
y = 70;
z = y – 5;
OR
y = 70;
y = y – 5;
z = y;
OR
y = 70;
OR
y = 70;
y -= 5;
z = y;
|
|
|
|
(f)
|
Write the output that will be
generated by the code given below:
int t;
int i;
for (i = 5; i <=10; i = i+5);
{
t = i+3;
System.out.printIn(“ “+t);
}
|
2
|
|
|
Ans.
|
8
13
|
|
|
4.
|
(a)
|
The
following code has some error(s). Rewrite the correct code underlining all
the corrections made.
int written,
interview;
written =
Integer.parseInt(jTextField1.getText());
interview =
Integer.parseInt(jTextField2.getText());
if (written
<80) OR (interview <15)
{
System.out.println(Not selected);
}
Else;
{
System.out.println(“Selected”);
}
|
2
|
|
|
Ans.
|
int written,
interview;
written =
Integer.parseInt(jTextField1.getText());
interview =
Integer.parseInt(jTextField2.getText());
if ( (written
<80) || (interview <15) )
{
System.out.println(“Not selected”);
}
else
{
System.out.println(“Selected”);
}
|
|
|
|
(b)
|
How many times will the following loop
execute:
int z = 7, sum = 0;
do
{
sum =
sum + z;
z = z+2;
System.out.printIn(“ “+z);
}
while (z <=12);
|
2
|
|
|
Ans.
|
3 times
|
|
|
|
(c)
|
Rewrite the following program code
using IF ELSE IF instead of SWITCH statement.
String rem;
int code =
Integer.parseInt(jTextField1.getText()):
Switch(code)
{
case 1: rem =”Classes start on 8th
April”;
break;
case 2: rem =”Classes start on 10th
April”;
break;
case 3: rem =”Classes start on 12th
April”;
break;
default: rem =”Contact
Admin Office”;
}
|
2
|
|
|
Ans.
|
String rem;
int code =
Integer.parseInt(jTextField1.getText()):
if (code==1)
rem = ”Classes start on 8th April”;
else if (code==2)
rem = ”Classes start on 10th April”;
else if (code==3)
rem = ”Classes start on 12th April”;
else
rem =”Contact Admin Office”;
|
|
|
|
(d)
|
Write the values of sum and t after execution
of following code:
int sum, t;
sum = 27;
t = 3;
sum = sum 2 * (++t);
|
2
|
|
|
Ans.
|
sum = 35
t = 4
|
|
|
|
(e)
|
What will be the contents of
jTextField1 and jTextField2 after executing the following code:
String s = “Best”;
String r = “Luck”;
String z;
Z = r.concat (s);
jTextField1.setText(z);
jTextField2.setText(r.toUpperCase());
|
2
|
|
|
Ans.
|
jTextField1 = LuckBest
jTextField2 = LUCK
|
|
|
|
(f)
|
Seema is a junior programmer at ‘Avon
Shoe Factory’. She has created the following GUI in Netbeans.
•
3 items namely
shoes, sandals and slippers are manufactured by the factory.
•
A buyer can buy
more than one item @ a time.
•
Each pair of
shoes cost Rs1500.00 each pair of sandals cost Rs1000.00 and each pair of
slippers cost Rs500.00.
•
Amount to be
paid for that item will be displayed in front of the item.
•
For Eg: if shoe
is selected, the quantity enter is 20 then amount should be displayed as 30,000.
|
|
|
|
(a)
|
When “CALCULATE” is clicked, the
amount should be displayed in front of each item and total amount should be
displayed in appropriate Text Field?
|
3
|
|
|
Ans.
|
float qty1=0, qty2=0, qty3=0, amt1=0,
amt2=0, amt3=0, total;
if(jCB1.isSelected())
qty1=Float.parseFloat(jTF1.getText());
if(jCB2.isSelected())
qty2=Float.parseFloat(jTF2.getText());
if(jCB3.isSelected())
qty3=Float.parseFloat(jTF3.getText());
amt1=qty1*1500;
amt2=qty2*1000;
amt3=qty3*500;
total=amt1+amt2+amt3;
jTF4.setText(""+amt1);
jTF5.setText(""+amt2);
jTF6.setText(""+amt3);
jTF7.setText(""+total);
|
|
|
|
(b)
|
When “CLEAR” button is clicked, all
the Text Fields and Check Boxes should be cleared.
|
1
|
|
|
|
jTF1.setText("");
jTF2.setText("");
jTF3.setText("");
jTF4.setText("");
jTF5.setText("");
jTF6.setText("");
jTF7.setText("");
jCB1.setSelected(False);
jCB2.setSelected(False);
jCB3.setSelected(False);
|
|
|
|
(c)
|
When “STOP” button clicked, the
application should close.
|
1
|
|
|
Ans.
|
System. exit(0);
|
|
Saturday, 27 February 2016
11th & 12th IP 2015(Delhi) Common Assignment
Friday, 26 February 2016
11th & 12th IP 2012(Ooutside.Delhi) common assign
|
5-(c)
ANS
|
Consider the Table SHOPPI given below. Write command in MySql for (i)
to(iv) and output for (v) to(vii)
Table SHOPPI:
i) To display names of the items whose
name starts with ‘C’ in ascending order of Price.
ii) To
display code, Item name and city of the products whose quantity is less then
100.
iii) To
count distinct Company from the table.
iv) To insert a new row in the table Shoppi
‘110’,’Pizza’,’Papa Jones’,’120’,’Kolkata’,50.00.
v) Select Item from Shoppi where Item
IN(“jam”,”Coffee”);
vi) Select count(distinct(City) ) from
Shoppi;
vii) Select MIN(qty) from Shoppi where
City=“Mumbai”;
i)
Ii)
iii)
iv)
v)
vi) 3
vIi)
|
7
1
1
1
1
1
1
1
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subscribe to:
Comments (Atom)