questions for Java
are character 2 and integer 2 represented by the same sequence of 0s and 1s?
what is a resudent program ?
(in simple english) What is a class?
After the execution of the code segment shown below, what value will x hold and what value will y hold?
int x = 1;
int y;
y = x;
y = 2;
After the execution of the code segment shown below, will x and y refer to the same
object or different objects?
BankAccount x = new BankAccount("A10", "Smith");
BankAccount y;
y = x;
y.deposit( 100 );
a) What are the differences between a Java applet and a Java stand-alone application
program?
b) Suppose an applet is being displayed.
i) If we resize the applet, the init method will be called as a result of the action. Is
this true or false?
ii) If we resize the applet, the paint method will be called as a result of the action.
Is this true or false?
The following code reads in the duration of an event in seconds. Complete the code to display
the duration in days, hours, minutes, and seconds. As an example, if the user enters the value
3750 (= 3600 + 120 + 30), the output should be:
The event lasts 0 days 1 hours 2 minutes and 30 seconds
(Assume that the user input is always a valid integer.)
import java.io.*;
public class Convert
{
public static void main(String [] args) throws IOException
{
BufferedReader keyboard = new BufferedReader(
new InputStreamReader(System.in));
System.out.print("Enter the duration of the event " +
"in seconds: ");
int duration = Integer.parseInt(keyboard.readLine());
int days;
int hours;
int minutes;
int seconds;
Write an applet that displays the number of mouse clicks. Initially it displays 0, and then
increases the number by 1 each time the user clicks the mouse on the applet.
Note: The MouseListener interface has the following methods:
public void mouseClicked(MouseEvent e)
public void mouseEntered(MouseEvent e)
public void mouseExited(MouseEvent e)
public void mousePressed(MouseEvent e)
public void mouseReleased(MouseEvent e)

