Download 1. whats the start do in applet cycle and when we use it? [2 makrs

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
1. whats the start do in applet cycle and when we use it? [2 makrs]
2.Write the syntax to load the oracle driver . [2 marks]
3. What the given code do ?
ResultSet rs=TYPING_SCROLL_INSENSITIVE
[3 marks]
4.what problem we faced in interprtr and how do we handle that situation ?[3 mraks]
5. write coding for while lope in ResultSet6. (columns ) method a table was given [5 makrs]
6. write any five GUI based component ? [5 marks
Almost all paper was difficult
Only 2 mcq’z from past paper
Q1
what type of a driver odbc-jdbc bridge? And why we cal so. 2 mrks
Q2
What is the difference b/w socket and server socket, also give a java syntax of socket and
Server socket. 5 mrks
Q3
If we does not set the width and hight of applet. 3 options were given we have to chose one
1 it will not compile
2 compile but not visible
I don’t remember the last one
Q4
One advantage and disadvantage of rowset rather than normal database 3 mrks
Q5
Wht is the disadvantage of interface in implementation ? 2mrks
Permalink Reply by marri on December 20, 2013 at 6:38pm
Asalamualikum .....my todays paper.....
write the code of the ResultSetDataMeta rs the 2nd column . 2 marks
write the code of given queiry .
changed the name of student NaeemKhan where its id is 10. 2 marks
note:
table name is Student.
column name is Std_name
column name of id is std_id.
Differentiation between Named vs. Anonymous object with example
code? 3 marks
(paintBorder, paintComponent, paintchildern )methods are used in java.
write their order in java? 3 marks.
write a graph code in which you draw a pink rectangular and a string
show “ i am a student” 5 marks.
The given code is Mouse listener code you have change the code to stop
the implementation of interface or sath mai adapter method given tha. 5
marks.
1. import java.awt.*;
2. import javax.swing.*;
3. import java.awt.event.*;
4. public class EventsEx implements MouseMotionListener ,
WindowListener {
5. JFrame frame;
6. JLabel coordinates;
// setting layout
7. public void initGUI ( ) {
// creating event generator
8. frame = new JFrame();
9. Container cont = frame.getContentPane();
10. cont.setLayout(new BorderLayout( ) );
11. coordinates = new JLabel ();
12. cont.add(coordinates, BorderLayout.NORTH);
// registring mouse event handler with generator
13. frame.addMouseMotionListener(this);
// registering window handler with generator
14. frame.addWindowListener(this);
15. frame.setSize(350, 350);
16. frame.setVisible(true);
17. } // end initGUI method
//default constructor
18. public EventsEx ( ) {
19. initGUI();
20. }
// MouseMotionListener event hadler handling dragging
21. public void mouseDragged (MouseEvent me) {
22. int x = me.getX();
23. int y = me.getY();
24. coordinates.setText("Dragged at [" + x + "," + y + "]");
25. }
// MouseMotionListener event handler handling motion
26. public void mouseMoved (MouseEvent me) {
27. int x = me.getX();
28. int y = me.getY();
29.
30. coordinates.setText("Moved at[" + x + "," + y + "]");
31. }
// window listener event handler
32. public void windowActivated (WindowEvent we) { }
33. public void windowClosed (WindowEvent we) { }
34. public void windowClosing (WindowEvent we) {
35. JOptionPane.showMessageDialog(null, “Good Bye”);
36. System.exit(0);
37. }
38. public void windowDeactivated (WindowEvent we) { }
39. public void windowDeiconified (WindowEvent we) { }
40. public void windowIconified (WindowEvent we) { }
41. public void windowOpened (WindowEvent we) { }
42. public static void main(String args[]) {
43. EventsEx ex = new EventsEx();
44. }
45. } // end class
best of luck .......
3 codes thy error find krny thy
1 5 num ka
do 3 num k
1 code inner classes wala tha
1 applet wala
r 1 paint wala
transiant key word q use hta hy (2)
next() kya return krta hy (2)
r update query likhni thi 5 numki
baqi 20 mcqs thy
Today Paper
Total Questions = 26
Total Marks = 40
Total MCQs of 1 Mark = 20
Short Subjective Question of 2 Marks = 2
Subjective Question of 3 Marks = 2
Subjective Questions of 5 Marks = 2
Question No 1 MARKS 2
Write a given connection URL in string variable conURL. How will you connect to MS Access
database using conURL in your java program?
Question No 2 MARKS 2
Complete syntax of paint Border method
Question No 3 MARKS 3
Write java code that will update name Ali to Ahmed on 5th row. Consider the column name is
sname note write only necessary code
Question No 4 MARKS 3
Methods (paintBorder, paintChildren, paintComponent) write correct order of methods call in if
these methods are called
Question No 5 MARKS 5
Write an alternative of atream of byte which is easy to use. How willl your solution benefit us
Question No 6 MARKS 5
Operator Text field and answer JLabels are already created?
1. 1.
Adapter classes have been defined for listener interfaces except ______ interface.
MouseListener
KeyListener
WindowListener i think correct option window listener hai
ActionListener
1. 2.
You can ---------to a network using sockets.
Read
Write
Read/Write (Page 222)
None of these
1. 3.
A class that is defined in another class is called ________.
Private class
Public class
Inner class
correct option
Derived class
1. 4.
Which block always execute whether exception occurs or not.
Finally block
1. 5.
2nd phase of java programming
Compile
1. 6.
correct option.
correct option.
Person DSN url
String conURL = “jdbc:odbc:personDSN;
correct option
5 marks Question:
1. Painting a swing component has three methods, define functionality of each. And also mention
which methods are not recommended to override or invoke. pg#186
2. Related about Mouse Listener interface. pg#130
3 marks Question:
1. Result set rs method to update, move forward and backward. Consider a conection method…es
type ka tha sai yad ni hai.
2. Aik program tha jis Mai jo draw krna wo 100 location pe draw ho.. ye b sai yad ni
2 marks Question:
1. Usage of getMaxRows and setMaxRows. Pg#158
2. Write unfilld circle code
write a simple java progrm to show events
click,exit,drag move enter(5)
ak tha k serliztn ka ak prgram bnana tha(5)
2 num ka tha ak
when we call matadata functn on "con" objct
what does it do(3)
can a anonyms class solve our prblm of multiple inheritnce (2)
any three function of paint compnent method(2)
what prblm you can fac using adoptor(3)
how u will handle it
it was very dfclt for me :(
best of luck
1.
2.
3.
4.
5.
6.
differnce b/w input/outputstream and read/write object.
differnce b/w mouse dragged and mouse move.
draw code for word"java " in 100 differnce location show.
Resultset give us answer of some question writhe thses.
code give change it into jfram extend
why action listner have never adopter class.
question asay he thya wording differnenent thi .
mcqus b ziyada last 7 lec ma sa thya.
1.
Why do we have getMaxRows and setMaxRows methods? 2 marks
2. In java how it is possible to get the name of a specific column in the ResultSet? 2marks
3. Why this statement is called connection url? Explain by relating it to browser url?
“jdbc:odbc:person DSN”
4. Write a method that display a string ”I am student” at random location on the screen having
size 1200*1000?
5. Write method that displays triangle using line times, Each time a triangle displays it at
different location?
6. Write program that extend adapter class for mouse click event, when mouse is clicked in area
of frame it displays a dialog box showing msg “mouse clicked”. Import required pakage. Use
following code to complete all requirement.
Public class EventsEx{
//put your code here
Public void initGUI(){
//put your code here
Frame.set DefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Frame.SetSize(350,350);
Frame.SetVisible(true);
}
End init GUI method
Public EventdEx(){
Init GUI();
}
//put your code here
Public static void main (string args[]){
Event.Ex ex new EventEx();
}
}
New MCQS
1. Which database allows us to work having closed connection?
a)
Mysql
b)
postgreSQL
c)
SQL
d)
SQLite
2. If a JPanel has a triangle drawn on it which of the following method will display it
a)
PaintBorder()
b)
Paint()
c)
paintChildren()
d)
paintComponent()
3. Window Adaptor class implements WindowListener interface and provide the definition of all
method inside ………………………
a)
WindowListener interface
b)
Inner Class
c)
Outer class
d)
Window adaptor class
4. Even handling is _______________ step process.
a)
1
b)
2
c)
3
d)
4
5. Which of the following is not the method of ResultSetMetaData class.
a)
Previous()
b)
isReadOnly()
c)
getColumnDisplay size()
d)
getColumnCount()
6. The code generate following output
Student s1, s2, s3, s4
S1= new student();
S2= new student();
a)
1
b)
2
c)
3
d)
4
write a simple java progrm to show events
click,exit,drag move enter(5)
ak tha k serliztn ka ak prgram bnana tha(5)
2 num ka tha ak
when we call matadata functn on "con" objct
what does it do(3)
can a anonyms class solve our prblm of multiple inheritnce (2)
any three function of paint compnent method(2)
what prblm you can fac using adoptor(3)
how u will handle it
it was very dfclt for me :(
best of luck
1
whats the start do in applet cycle and when we use it
ans :
To start the applet's execution

• For example, when the applet's loaded or when the user revisits a page that contains the
applet

• start( ) is also called whenever the browser is maximized
2
.Write the syntax to load the oracle driver
ans:
Class.forName(“oracle.jdbc.driver.OracleDriver”);
3
what dose codes do
ResultSet rs=TYPING_SCROLL_INSENSITIVE
ResultSet.TYPE_SCROLL_INSENSITIVE,
The following code fragment, illustrates how to make a ResultSet object that is scrollable and
updatable.
String sql = “SELECT * FROM Person”;
PreparedStatement pStmt = con.prepareStatement(sql,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = pStmt.executeQuery( );
Two constants have been used of ResultSet class for producing a ResultSet rs that is
scrollable, will not show changes made by others and will be updatable

4.
What DO MaxRows (int) & setMaxRows(int) methods
• Used for determines the number of rows a ResultSet may contain

• By default, the number of rows are unlimited (return value is 0), or by using
setMaxRows(int), the number of rows can be specified.
5
write any five GUI based component
1. BUTTON
2. Label
3. Text filed
4.Text area
6



• paint( ) is called for the first time when the applet becomes visible
• Whenever applet needs to be repainted, paint( ) is called again
• Do all your painting in paint( ), or in a method that is called from paint( )
7.

define paint( ) in applet life cycle
what is and why we use : JDBC - ODBC Bridge
• Translates all JDBC calls into ODBC (Open Database Connectivity) calls and
send them to the ODBC Driver


• Generally used for Microsoft database.
• Performance is degraded
8.
What is the difference b/w socket and server socket, also give a java syntax of socket and
Server socket. 5 mr
A socket is one endpoint of a two-way communication link between two programs
running generally on a network.

• A socket is a bi-directional communication channel between hosts. A computer on a
network often termed as host.

The server listens through a special kind of socket, which is named as server socket.
• The sole purpose of the server socket is to listen for incoming request; it is not used
for communication
Syntex for socket
Socket s = new Socket(“serverName”, serverPort) ;
serverName: Name or address of the server you wanted to connect such as
http://www.google.com or 172.2.4.98 etc. For testing if you are running client and server
on the same machine then you can specify “localhost” as the name of server

• serverPort : Port number you want to connect to
Syntex for server socket
Create a Server Socket
In order to create a server socket, you will need to specify port no eventually on which server
will listen for client requests.
ServerSocket ss = new ServerSocket(serverPort) ;

• serverPort: port local to the server i.e. a free port on the server machine. This is the same
port number that is given in the client socket constructor
9
what is disadvantage of interfaces
One disadvantage of interfaces is that one you publish them to other coders outside your own
control, they represent a public commitment which can be difficult to change later. You don't
know who else is using the interface and you don't know how, so you can't just add a new
method to the interface without risking breaking the code of existing clients (if/when they
upgrade). In comparison, if you'd used an abstract or concrete class, you could just add a new
concrete method with no problems (usually).
It's possible to work around this b
10.
ager kisi ko inn questions ka answer patta hain to please share ker deyn
1. Which database allows us to work having closed connection?
a)
Mysql
b)
postgreSQL
c)
SQL
d)
SQLite
2. If a JPanel has a triangle drawn on it which of the following method will display it
a)
PaintBorder()
b)
Paint()
c)
paintChildren()
d)
paintComponent()
1-Write a method that display a string ”I am student” at random location on the screen having
size 1200*1000?
2-Write method that displays triangle using line times, Each time a triangle displays it at
different location?
3- why action listner have never adopter class.
4-changed the name of student NaeemKhan where its id is 10. 2 marks
note:
table name is Student.
column name is Std_name
column name of id is std_id.
5-can a anonyms class solve our prblm of multiple inheritnce
6-Write unfilld circle code
7-If we does not set the width and hight of applet. 3 options were given we have to chose one
1 it will not compile
2 compile but not visible
I don’t remember the last one
8-One advantage and disadvantage of rowset rather than normal database 3 mrks
CS506 Today paper
1.
2.
3.
4.
5.
What is the process of get metadata in java language?(2)
If we use scroll /update and same time use previous() exception throws reason?(2)
Which methods are use to executes queries and when they are used?(3)
Write three functions of paintComponent() method.(3)
Write a GUI program in which on mouse click a message comes “mouse is clicked” don`t
implement interface assume class is adapter class.(5)
6. Complete the connection and message send and receive code of the client side . client sends two
numbers to the server and the server gives the answer in a single string. (5)
Mera Cs506 ka paper buhot bura hova sab question buhot ajeeb or all coding the or kuch b nhi
tha All mcqs new koie old nhi tha
write the result set code onf 2nd width column
write the code of transparent triangle and enclose the circle with orange color in it withpaint
component
write the query EMP_ID and EMP_NAME to update etc
bakie yad nhi mujay woh b coding the
AOA guyz here is my cs506 midterm paper dated 26th Dec,2013 at 12 pm
MCQs were ez and 2 to 3 were different:
HTTP lies in -----------Transport layer
Presentation layer
Network layer
application layer
Rowsets are in ------------------- package
java.awt
java.util
javax.swing
java.sql
Q1: differentiate b/w PrintWriter and BufferedReader w.r.t their data conversion abilities 2
marks
Q2: what command or method is used to move to a specific row in resultset to get some data? 2
marks
Q3: What java paint methods would be called and in what order for there is a JPanel and a
triangle drawn on
it and a Button is painted? 3 mrks
Q4: Write 3 limitations of default ResultSet? 3marks
Q5: Write the steps o create the complete steps for making connection ad getting data from a
able in
database? 5 marks
Q6: Complete the code for establishing connection and send and receive message code of the
Server side . client sends two numbers in a single string to the server and the server sends the
sum of these
no.s in a single string. 5 marks
Stay Blessed and remember me in ur prayerz!!!!