Java Old Paper solution || 2019
Group B
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
*/ import java.awt.*; import java.awt.event.*; class ButtonDemo extends Frame implements ActionListener { Button b1,b2,b3; Label l; ButtonDemo() { setLayout(new FlowLayout()); b1=new Button("RED"); b2=new Button("BLUE"); b3=new Button("GREEN"); l=new Label(""); add(b1); add(b2); add(b3); add(l); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); } public void actionPerformed(ActionEvent e) { if(e.getSource()==b1) { l.setText("RED"); } else if(e.getSource()==b2) { l.setText("BLUE"); } else if(e.getSource()==b3) { l.setText("GREEN"); } } public static void main(String args[]) { ButtonDemo b=new ButtonDemo(); b.setSize(400,400); b.setVisible(true); } } |
Q.no 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import java.sql.*; public class Marvel { public static void main(String[] args) { try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Marvel", "root", "root"); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from Movie where genre='action'"); while (rs.next()) System.out.println(rs.getInt(1) + " " + rs.getString(2) + " " + rs.getString(3)); con.close(); } catch (Exception e) { System.out.println(e); } } } </code> |
Q.no 6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
import java.awt.*; import java.awt.event.*; import java.applet.*; /* <applet code="MouseListenerDemo" width=300 height=100> </applet> */ public class MouseListenerDemo extends Applet implements MouseListener { String msg=""; int mouseX=0,mouseY=0; public void init() { addMouseListener(this); } public void mouseClicked(MouseEvent me) { mouseX=0; mouseY=10; msg="Mouse Clicked"; repaint(); } public void mouseEntered(MouseEvent me) { mouseX=0; mouseY=10; msg="Mouse Entered"; repaint(); } public void mouseExited(MouseEvent me) { mouseX=0; mouseY=10; msg="Mouse Exited"; repaint(); } public void mousePressed(MouseEvent me) { mouseX=me.getX(); mouseY=me.getY(); msg="Down"; repaint(); } public void mouseReleased(MouseEvent me) { mouseX=me.getX(); mouseY=me.getY(); msg="Up"; repaint(); } public void paint(Graphics g) { g.drawString(msg,mouseX,mouseY); } } |
How is servlet depoyed ? Explain. Servlets are usually deployed in web containers, such as Apache Tomcat. The web container provides an environment for servlets to run in, managing threading, connection pooling, security, and other services. When a web server receives a request for a […]
Continue Reading