Java Applets and AWT Graphics

Test your knowledge with basics of Java Applets and AWT graphics programming, including Applet attributes, lifecycle methods, GUI components, and drawing operations.

12 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

In the following Java program, it was found that these statements have generated an exception of Array Index out of bound Exception.

int b[ ] = {10,20,30};
b[50] = 100 ;

Choose the correct catch statement for the above code.

  1. ```java
    catch (ArrayIndexOutOfBoundsException aie) {
    aie.printStackTrace();
    System.out.println("array size is less than what you are trying to access")
    }
  2. java catch (ArrayIndexOutOfBoundsException aie) { System.out.println("array size is less than what you are trying to access") }
  3. ```java
    catch (aie) {
    aie.printStackTrace();
    System.out.println("array size is less than what you are trying to access")
    }
  4. ```java
    throw (ArrayIndexOutOfBoundsException aie) {
    aie.printStackTrace();
    System.out.println(array size is less than what you are trying to access ')
    }
  5. ```java
    throw (aie) {
    aie.printStackTrace();
    System.out.println(array size is less than what you are trying to access)
    }
Question 2 Multiple Choice (Single Answer)

Which of the following attributes of an Applet class specifies the path of the class file?

  1. CODE
  2. CODEBASE
  3. HEIGHT
  4. WIDTH
  5. ALIGN
Question 3 Multiple Choice (Single Answer)

For what purpose is the given JAVA statement required?
horiz1.add(Box.createHorizontalbox();

  1. To create a horizontal box on screen
  2. To create a horizontal space between a defined label and defined text field
  3. To create a position of a symbol on the screen
  4. To create a vertical space between a defined label and defined text field
  5. All of the above
Question 4 Multiple Choice (Single Answer)

Which of the following specific codes does a web server send using its HTML page to a client server?

  1. ASCII code of a character
  2. Command to client server to report an Exception
  3. JAVA Applet
  4. RDBMS Applet
  5. Only 3 and 4
Question 5 Multiple Choice (Single Answer)

when we call repaint() method for a component, the AWT calls the method:

  1. paint()
  2. update()
  3. show()
  4. draw()
  5. none of the above
Question 6 Multiple Choice (Single Answer)

What is the virtual machine that a web browser contains at the client side called?

  1. JAVA Applet
  2. Virtual program
  3. Search Engine
  4. Applet Engine
  5. Threads
Question 7 Multiple Choice (Single Answer)

Which of the following adjustment events of scroll bar is used to generate an absolute event?

  1. BLOCK_DECREMENT
  2. BLOCK_INCREMENT
  3. TRACK
  4. UNIT_DECREMENT
  5. UNIT_INCREMENT
Question 8 Multiple Choice (Single Answer)

Which of the following parameters in applet tag specifies the number of milliseconds between each billboard?

  1. Billboards
  2. Delay
  3. Bgcolor
  4. None of these
Question 9 Multiple Choice (Single Answer)

Which of the classes in java.awt package supports automated testing of AWT based applications?

  1. Window
  2. Robot
  3. Panel
  4. None of these
Question 10 Multiple Choice (Single Answer)

Which of the following classes in Java is used to encapsulate a combo box in an applet program?

  1. JRadioButton
  2. JCheckBox
  3. JComboBox
  4. None of these
Question 11 Multiple Choice (Single Answer)

What will be the output of the following code?

class Apple {
 protected int i = 20;
}
class Banana extends Apple {
 void show() {
  System.out.println(i);
 }
}
class Cat extends Banana {
 void disp() {
  System.out.println(i); //i is also available here	
 }
}
public class Fruit {
 public static void main(String[] args) {
  Cat c = new Cat();
  c.disp();
 }
}
  1. 0
  2. Compile Time Error
  3. 20
  4. 020
  5. 200
Question 12 Multiple Choice (Single Answer)

What will be the output of the following statement?
g.fillRect(40,40,200,20);

  1. Displays a rectangle of 200X200 pixels starting with top left corner at 40X40 pixels
  2. Displays a rectangle of 40X400 pixels starting with top left corner at 200X200 pixels
  3. Displays a circle of 200X200 pixels starting with top left corner at 40X40 pixels
  4. Displays a circle of 40X40 pixels starting with top left corner at 200X200 pixels
  5. None of the above