Académique Documents
Professionnel Documents
Culture Documents
Q1. Develop an application to prepare students results on the basis of marks entered. A sample screen shot is being shown
below : [5]
Q2. WAP in Java to print a table, when user click on “Click here” jButton control. [2]
if ( code = = 1 )
Month = "January" ;
else if ( code = = 4 )
Month = "April" ;
else if ( code = = 8 )
Month = "August" ;
else
Month = "No Match" ;
4. What will be the output of the following code fragment when the value of ch is ‘B’ :
switch (ch) {
case ‘A’ : ta1. append (" Grade A " );
case ‘B’ : ta1. append (" Grade B " );
case ‘C’ : ta1. append (" Grade C " );
case ‘D’ : ta1. append (" Grade D " );
break ;
default : ta1. append (" Grade F " );
}
5. State the output of the following code :
int a = 10 , b = 5 ;
if ( a > b ) {
if ( b > 5 )
tf1. setText ( " b is " + b ) ;
}
else
tf1. setText ( "a is " + a ) ;
(a) Find the error from the following code segment and rewrite the corrected code underlining
the correction made.
int x,y;
x=-20
y=2.9;
z=x+y;
system.out.println(“”+z);
int i,j;
j=0;
for(i=1;i<=5;i++)
System.out.println(j+” “);
j+=2;
(c) Convert the following code segment into switch case construct
int Choice;
Choice=Integer.parseInt(ChoiceTextField.getText());
If(Choice = = 1)
{
else
If(Choice = = 2)
else
if(Choice = = 3)
else
System.out.println(“Invalid Entry”);
(i) int s = 14 ;
if (s < 20 )
else
if ( ch = = ‘E’ )
eastern + + ;
if ( ch = = ‘W’ )
western + + ;
if ( ch = = ‘N’ )
northern + + ;
if ( ch = = ‘S’ )
southern + + ;
else
unknown + + ;