Category: Uncategorized
new
ss a 12 13 14. Design an asynchronous MOD-440 Counter. 15 16 17 b
Continue ReadingJava old Papers Solution 2016 || BIM STUDY NOTES
Year 2016 Group B Q.no 2 Write a swing program to add two numbers given as input by user.
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 |
import java.awt.*; import javax.swing.*; import javax.swing.event.*; import java.awt.event.*; public class T2016_2 extends JFrame implements ActionListener{ JTextField t1,t2; JLabel sum; JButton b; public T2016_2(){ t1=new JTextField(); t2=new JTextField(); sum=new JLabel(""); b=new JButton("Add"); setLayout(new GridLayout(4,1)); add(t1); add(t2); add(b); add(sum); setSize(200,400); setVisible(true); b.addActionListener(this); } public void actionPerformed(ActionEvent e){ int n1=Integer.parseInt(t1.getText()); int n2=Integer.parseInt(t2.getText()); int s=n1+n2; sum.setText("Sum is: "+s); } public static void main(String[] args) { new T2016_2(); } } |
Q.no 3 Write an applet to check whether given word by user is of length 5 or not.
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 |
import java.applet.*; import java.awt.*; import java.awt.event.*; public class T2016_3 extends Applet implements KeyListener{ TextField t1; Label lab; public void init(){ t1=new TextField(); add(t1); lab=new Label(); add(lab); setSize(300,300); setLayout(new GridLayout(2,1)); } public void start(){ t1.addKeyListener(this); } public void keyTyped(KeyEvent e){} public void keyPressed(KeyEvent e){} public void keyReleased(KeyEvent e){ String a=t1.getText(); if(a.length()==5){ lab.setText(a+" is of length 5"); } else{ lab.setText(a+" is not of length 5"); } } } |
4. Write a JSP program to display ” Apache Tomcat” eight times.
1 2 3 4 5 6 7 8 9 10 11 |
<html> <head> </head> <body> <% for(int i = 1; i <= 8; i++) { out.println("Apache Tomcat <br />"); } %> </body> </html> |
5. Write a program […]
Continue Reading