Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Advanced Java Practical Slip 2 Answers

 


Q.1. Advanced Java:

A) Write a JSP program to check whether given number is Perfect or not. (Use Include

directive).

Answer :

 Slip2A.html

<html>

 

<body>

    <h1>Find Perfect Number</h1>

    <form action="http://127.0.0.1:8080/java/Slip2A.jsp" method="GET">

        Enter Number : <input type='text' name='no'>

        <input type='submit' value='SUBMIT'>

    </form>

</body>

 

</html>

 

Slip2A.jsp

<%@ page language="java" %>

<html>

    <body>

        <%

            int n = Integer.parseInt(request.getParameter("no"));

            int n1=0;

            for(int i=1; i<n; i++){

                if(n%i==0){

                    n1+=i;

                }

            }

            if(n1==n){

                out.println("Perfect Number");

            }else{

                out.println("not Perfect Number");

            }

        %>

    </body>

</html>


B) Write a java program in multithreading using applet for drawing flag.

Answer :

import java.awt.*;

 

public class Slip2B extends Frame{

 

    int f = 0;

 

    public Slip2B(){

        Signal s = new Signal();

        s.start();

        setSize(500,500);

        setVisible(true);

    }

 

    public void paint (Graphics g){

        switch (f){

            case 0 :

            g.drawLine(150, 50, 150, 300);

            case 1 :

            g.drawRect(150, 50, 100, 90);

        }

    }

 

class Signal extends Thread{

    public void run(){

        while(true){

            f = (f+1)%2;

            repaint();

            try{

                Thread.sleep(1000);

            }catch(Exception e){

 

            }

        }

    }

}

    public static void main(String args[]){

        new Slip2B();

    }

}


Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Advanced Java Practical Slip 2 Answers Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Advanced Java Practical Slip 2 Answers Reviewed by technical_saurabh on September 21, 2022 Rating: 5

No comments:

Powered by Blogger.