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.
Questions
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.
- ```java
catch (ArrayIndexOutOfBoundsException aie) {
aie.printStackTrace();
System.out.println("array size is less than what you are trying to access")
} -
java catch (ArrayIndexOutOfBoundsException aie) { System.out.println("array size is less than what you are trying to access") } - ```java
catch (aie) {
aie.printStackTrace();
System.out.println("array size is less than what you are trying to access")
} - ```java
throw (ArrayIndexOutOfBoundsException aie) {
aie.printStackTrace();
System.out.println(array size is less than what you are trying to access ')
} - ```java
throw (aie) {
aie.printStackTrace();
System.out.println(array size is less than what you are trying to access)
}
Which of the following attributes of an Applet class specifies the path of the class file?
- CODE
- CODEBASE
- HEIGHT
- WIDTH
- ALIGN
For what purpose is the given JAVA statement required?
horiz1.add(Box.createHorizontalbox();
- To create a horizontal box on screen
- To create a horizontal space between a defined label and defined text field
- To create a position of a symbol on the screen
- To create a vertical space between a defined label and defined text field
- All of the above
Which of the following specific codes does a web server send using its HTML page to a client server?
- ASCII code of a character
- Command to client server to report an Exception
- JAVA Applet
- RDBMS Applet
- Only 3 and 4
when we call repaint() method for a component, the AWT calls the method:
- paint()
- update()
- show()
- draw()
- none of the above
What is the virtual machine that a web browser contains at the client side called?
- JAVA Applet
- Virtual program
- Search Engine
- Applet Engine
- Threads
Which of the following adjustment events of scroll bar is used to generate an absolute event?
- BLOCK_DECREMENT
- BLOCK_INCREMENT
- TRACK
- UNIT_DECREMENT
- UNIT_INCREMENT
Which of the following parameters in applet tag specifies the number of milliseconds between each billboard?
- Billboards
- Delay
- Bgcolor
- None of these
Which of the classes in java.awt package supports automated testing of AWT based applications?
- Window
- Robot
- Panel
- None of these
Which of the following classes in Java is used to encapsulate a combo box in an applet program?
- JRadioButton
- JCheckBox
- JComboBox
- None of these
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();
}
}
- 0
- Compile Time Error
- 20
- 020
- 200
What will be the output of the following statement?g.fillRect(40,40,200,20);
- Displays a rectangle of 200X200 pixels starting with top left corner at 40X40 pixels
- Displays a rectangle of 40X400 pixels starting with top left corner at 200X200 pixels
- Displays a circle of 200X200 pixels starting with top left corner at 40X40 pixels
- Displays a circle of 40X40 pixels starting with top left corner at 200X200 pixels
- None of the above