Anda di halaman 1dari 4

Class – XI

Subject – Informatics Practices

Q1. Develop an application to prepare students results on the basis of marks entered. A sample screen shot is being shown
below : [5]

 Decide what controls are required on


your own.

Q2. WAP in Java to print a table, when user click on “Click here” jButton control. [2]

3. Rewrite the following program code using a switch statement :

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 ) ;

5 Answer the following questions:

(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);

(b) Find the output of the following code segment:

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)
{

System.out.println(“You Have Opted Arts”);

else

If(Choice = = 2)

System.out.println(“You Have Opted Commerce”);

else

if(Choice = = 3)

System.out.println(“You Have Opted Science”);

else

System.out.println(“Invalid Entry”);

(i) int s = 14 ;
if (s < 20 )

System . out . print ( “Under“ ) ;

else

System . out . print ( “Over“ ) ;

System . out . println ( “the limit“ ) ;


Rewrite the following fragment using switch :

if ( ch = = ‘E’ )

eastern + + ;

if ( ch = = ‘W’ )
western + + ;

if ( ch = = ‘N’ )

northern + + ;

if ( ch = = ‘S’ )

southern + + ;

else

unknown + + ;

Anda mungkin juga menyukai