Académique Documents
Professionnel Documents
Culture Documents
(a)
progatoin1();
try{
progation2();
catch(ArithmeticException e){
System.out.println(e);
(b) 20
__________________________________________________________________________________
_________________
QSN 2
(a)
package aevent;
import java.awt.Color;
import java.awt.event.*;
import javax.swing.*;
JTextArea area;
JTextArea area1;
JButton area2;
JLabel area3;
JLabel area4;
JFrame f;
Text(){
f = new JFrame();
area3.setBounds(40,30,60,30);
area4.setBounds(40,80,60,30);
area2.setBounds(50,130,300,30);
area.setBounds(110,30,200,30);
area.setBackground(Color.red);
area1.setBounds(110,80,200,30);
area1.setBackground(Color.red);
area2.addActionListener(this);
f.add(area);
f.add(area1);
f.add(area2);
f.add(area3);
f.add(area4);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
try{
}catch(Exception r){
new Text(); }}
(b). Because abstract means implements no functionarity and static means There is functionality
evenif you dont have an object instance and that is a logical contradiction.
__________________________________________________________________________________
____________________________________
QSN 3.
(a)
ackage savingaccount;
import java.util.Scanner;
SavingAccount(){
annualInterestRate = 0;
return rate;
savingBalance = savingBalance+((savingBalance*annualInterestRate)/12);
package savingaccount;
import java.util.Scanner;
double rate;
rate= input.nextInt();
x1.modifyInteretRate(rate);
server1.calculateMonthlyInterest(20000);
server2.calculateMonthlyInterest(30000);
(B). methode sum with two parameters integers has arleady defined in class calculation
__________________________________________________________________________________
____________________
QSN 4.
(b).
package userpromt;
try{
num.Numbers();
}catch(Exception e)
System.out.println(e);
}
package userpromt;
import java.util.Scanner;
class2(){
summation = 0;
product = 1;
average = 0;
int avr,sum ;
int product;
avr = average;
sum = summation;
int largest = 0;
int smallest = 0;
int odd=0;
int even=0;
product = this.product;
System.out.print("Enter an interger");
num[i]= input.nextInt();
if(num[i]<=0){
throw new Exception("Error The integer must be greater greater than zero");
}
else{
if((num[i]%2) == 0){
even = even+1;
else{
odd = odd+1;
largest = num[0];
smallest = num[0];
if(num[i]>largest){
largest = num[i];
else if(num[i]<smallest){
smallest = num[i];
sum = sum+num[i];
product = product*num[i];
avr = sum/num.length;
System.out.println("Sum = "+sum);
System.out.println("product = "+product);
System.out.println("average = "+avr);
checkSum(sum);
if(product<100){
else if(product==100){
else{
if(sum<100){
else if(sum==100){
else{
__________________________________________________________________________________
___________________________
QSN 5.
package theedimensionshape;
package theedimensionshape;
@Override
double area;
area = 4*3.14*radius*radius;
return area;
@Override
double volume;
volume = (4/3)*3.14*radius*radius*radius;
return volume;
}
package theedimensionshape;
double area;
area = 6*side*side;
return area;
double volume;
volume = side*side*side;
return volume;
package theedimensionshape;
}
__________________________________________________________________________________
_________________________________________________-
QSN 6.
(a)
import java.sql.*;
try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Connecting to database...");
conn = DriverManager.getConnection(DB_URL,USER,PASS);
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql;
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
(b). True