Logo

Java Questions Set 198:

Quiz Mode

What function in Java replaces the destructor function?

1
2
3
4

Solution:

What HTML tag is used for Java applets to communicate with a web page?

1
2
3
4

Solution:

How can a file be uploaded to a web server?

1
2
3
4

Solution:

class test{

public static void main (String[] args) {

  int x=1,y=16;

  x=x>>2;

  y=y>>x;

  System.out.println(~x);

}

}

1
2
3
4

Solution:

Which method of the StringBuffer class is used to concatenate a string representation to the end of the invoking StringBuffer object?

1
2
3
4

Solution:

class test {

public static void main (String[] args) {

   System.out.println('a'+0.89);

}

}

1
2
3
4

Solution:

Predict the output of the following Java code:

class Abekus {

public static void main(String[] args)

{

do {

System.out.print(1);

do {

System.out.print(2);

do{ System.out.print(3);

do{ System.out.print(4);} while(false);

} while(false);

} while (false);

} while (false);

}

}

1
2
3
4

Solution:

Predict the output of the following Java code.

class First {

    void display() {

System.out.println("Inside : First."); } }

class Second extends First {

    void display() {

System.out.println("Inside : Second."); } }

class Abekusmain {

    public static void main(String[] args) {

First obj1 = new First();

Second obj2 = new Second();

First ref;

ref = obj1;

ref.display();

ref = obj2;

ref.display(); }

}

1
2
3
4

Solution:

public void foo( boolean a, boolean b)
{
   if( a )
   {
       System.out.println("A"); /* Line 5 */
   }
   else if(a && b) /* Line 7 */
   {
       System.out.println( "A && B");
   }
   else /* Line 11 */
   {
       if ( !b )
       {
           System.out.println( "notB") ;
       }
       else
       {
           System.out.println( "ELSE" ) ;
       }
   }
}

1
2
3
4

Solution: