CS290 Java Programming Quiz Answers 1. Java does automatic garbage collection T Java Supports pointers F Java supports multiple inheritance F Java supports mutiple threads T Java code is case sensitive T All Java methods must have a return type F 2. Instance variable Valid within all methods in the class int count= 0; Class variable Valid within all methods in the class and any instances of the class static int totalcount =0 Local variable Valid within the method only int c; this variable Valid for this class this.count=45; super variable Valid for the super class super.count=3; 3. Write a Java program that creates a button and a list object. When the user clicks the button your program should add the word click1 to the list. The second click should add click2 to the list and so on public class MyApplet extends Applet implements ActionListener { List list; Button button; int counter=0; public void init() { list= new List(10,false); button = new Button("Add"); button.addActionListener(this); } public void actionPerformed(ActionEvent e) { Button b= (Button)e.getSource(); if (b.equals(button)) { counter++; list.add("click" + String.valueOf(counter)); } } 4. a. Font f= new Font(Font.Arial,Font.ITALIC,15) ; b. setBackground(Color.Magenta) ; c. t.sleep(3000); d. g,drawImage(picture.gif,40,50,this); e. Frame f= new Frame("My Cool Window"); f. URL myURL = new URL(www.mysite.com); g. final static int myconst=123; 5. Thread t1= new Thread(this); t1.setPriority(Thread.MAX_PRIORITY); t1.start(); Thread t2= new Thread(this); t2.setPriority(Thread.MIN_PRIORITY); t2.start();