Java Programming Solutions Part2
Java Programming Solutions Part2
Java Programming Solutions Part2
import java.util.Scanner;
while (number != 0) {
number /= 10;
if (result == originalNumber) {
} else {
}
12. WAP to create an interface and show its implementation in a class.
interface Drawable {
void draw();
System.out.println("Drawing Circle");
obj.draw();
13. WAP to create a package Calc with methods Sum() & Sub() and show their
implementation in a class.
package Calc;
return a + b;
return a - b;
import java.util.Scanner;
int reverse = 0;
while (number != 0) {
number /= 10;
}
System.out.println("Reversed number: " + reverse);
try {
} catch (Exception e) {
16. WAP to show working of throw and throws for handling exceptions.
} else {
try {
validateAge(16);
} catch (ArithmeticException e) {
import java.util.Scanner;
}
}
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
Button loginButton;
Label message;
password.setEchoChar('*');
add(userLabel);
add(username);
add(passLabel);
add(password);
add(loginButton);
add(message);
loginButton.addActionListener(this);
message.setText("Login Successful!");
} else {
import java.util.Vector;
vector.add("Apple");
vector.add("Banana");
vector.add("Cherry");
vector.remove("Banana");
import java.awt.*;
import javax.swing.*;
public BorderLayoutExample() {
setLayout(new BorderLayout());
setSize(300, 200);
setVisible(true);
}
public static void main(String[] args) {
new BorderLayoutExample();