2015 JAVA PROGRAMMING
|
||
Q.NO 2
(a)
|
Write the value of variable ‘C’ after execution of
the following code:
int d;
int c;
d=7;
c = (5*++d)%3;
|
1
|
Ans
|
1
|
|
(1 mark for correct answer)
OR
(1/2 mark to be awarded if 2 is given as answer on
account of
Student’s knowledge about * and % operators)
|
(b)
|
What is the difference between jTextField and jPasswordField
components?
|
1
|
Ans.
|
jTextField displays input / output characters as they are.
jPasswordfield does masking of keyboard input from user, using an
echo character ‘*’ by default.
|
|
(1 mark for correct difference)
OR
(1/2 mark for explaining any one)
|
||
(c)
|
In a SWITCH statement, what is the purpose of ‘default’ section?
|
1
|
Ans.
|
‘default’ section is used to execute statement(s), when none of
the specified cases mentioned match.
|
|
(1 mark for correct answer)
|
||
(d)
|
Write java code to assign the value 500 to variable x. Increase
the value of x by 50 and store it in variable y.
|
1
|
Ans
|
X = 500;
X += 50;
Y = x;
OR
X = 500;
x = x + 50;
y = x;
|
|
(1/2 mark for assigning 500 to x)
(1 mark for increasing value of x by 50)
|
||
(e)
|
Write the output that will be generated by the code given below:
Int I;
I = 7;
Int r;
r=8;
while (i<=10)
{
System.out.printIn (r*i);
I =i+2;
|
2
|
Ans
|
56
72
|
|
4-a)
|
The following code has some error(s). Rewrite the correct code
underlining all the corrections made.
int marks, temperature;
marks = jTextField.getText());
temperature =
Integer .parseInt (jTextField2.getText());
If (marks < 80) and (temperature >= 40)
{
System.out.printIn (“Not Good “);
}
else;
{
System.out.println( “ OK “);
}
|
2
|
Ans
|
int marks,
temperature;
marks = Integer.parseInt(jTextField.getText());
temperature =
Integer .parseInt (jTextField2.getText());
If( (marks < 80) && (temperature
>= 40) )
{
System.out.printIn (“Not Good “);
}
else
{
System.out.println( “ OK “);
}
|
|
4-b)
|
How many times will the following while loop execute?
int y = 7, sum = 0;
while(y <=15)
{
Sum = sum +
y;
y = y +2 ;
}
|
2
|
Ans
|
5 times
|
11th and 12th IP Java Programming 2013( Q 2 & Q 4 ) Outside Delhi common assignment
2(a)
|
which
property of palette list box is used to enter the list of items while working
in NetBeans?
|
1
|
||||||
ANS
|
model
property
|
|||||||
(b)
|
What is
the difference between the use of jTextField and JPasswordField in a form?
|
1
|
||||||
Ans
|
When we
type text into a JTextField control, it shows the characters in the control,
but in JPasswordField control the typed characters are shown as ( ) for
security.
|
|||||||
(c)
|
“the
variable/expression in the switch statement should either evaluate to an
integer value or string value”.
|
1
|
||||||
Ans
|
True
|
|||||||
(e)
|
How many
times will the following loops execute? Which one of them is entry control
and which one is exit control?
|
2
|
||||||
Loop1
int i=10,
sum=0;
While
(i>1)
{
Sum+=i;
i=3
}
Loop2
int i=10,
sum=0;
do
{
Sum+=i;
i-=3;
}while
(i>1);
|
||||||||
Ans
|
Following
loops will execute 3 times.
Loop 1 is
entry control loop and loop 2 is exit control loop.
|
|||||||
(f)
|
What will
be displayed in JTextField1 and jTextField2 after the execution of the
following loop?
|
2
|
||||||
ans
|
Output
jTextField1-5
jTextField2-9
|
|||||||