0% found this document useful (0 votes)
299 views

Advanced Java Model Answer Paper

This document is a model question paper for an Advanced Java Programming course, covering various topics such as AWT, Swing, JDBC, and Servlets. It includes multiple-choice questions, fill-in-the-blank questions, and code-related questions. The total marks for the paper are 70, and it is designed for diploma students in Computer Engineering/IT.

Uploaded by

Madhura Suroshe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
299 views

Advanced Java Model Answer Paper

This document is a model question paper for an Advanced Java Programming course, covering various topics such as AWT, Swing, JDBC, and Servlets. It includes multiple-choice questions, fill-in-the-blank questions, and code-related questions. The total marks for the paper are 70, and it is designed for diploma students in Computer Engineering/IT.

Uploaded by

Madhura Suroshe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 19
SOLVED MODEL QUESTION PAPER Advanced Java Programming ~ Diploma (Sem - V) Computer Engg/IT Program Group (CO/CM/IF/CW) ‘Time 12 Hours) 7 Total Marks :70 Remember Level (1 Mark each) chapter 4 Q4 Which class can be used to represent the Checkbox with a textual label tat can appear in @ ment? A. Menubar B. Memul C.CheckboxMenultem DiMenw 2 Q2 Which are various AWT controle from following ? A. Labels, Push buttons, Check boxes, Choice lst 2B. Text components, Threads, Srings, Servets, Vectors C. Labels, Strings, ISP, Netbeans, Sockets D. Push buttons, Servelts, Notepad, JSP tans. A) Chapter 2 Q1 JPanel and Applet use 5 their default layout. A. FlowLayout B. GridLayout C. BorderLayout D. GridBagLayout ias.2] Q2 —Mhich of the following is rue about AWT and Swing Component ? A. AWT Components create a process where as Swing Component create a thread B. AWT Components create a thread where as Swing Component create a process . Both AWT and Swing Component create a process D. Both AWT and Swing Component create a thread. os. £8) Chapter 3 Q4 Which ofthese methods is used 10 obtain the object that generated a WindowEvent ? A. getMethodd) B. getWindow C. getWindowEvent) D. getWindowObjectO Q2 Which of these methods is used to get x coordinate ofthe mouse ? A. getXO B. getXCoordinate) C. getCoordinateX0 D. getPointX. tans. 8} Q3 Which of these are constants defined in Windowvent class ? 4. WINDOW ACTIVATED B. WINDOW_CLOSED C. WINDOW_DEICONIFIED D. All ofthe mentioned thas. 0) Q4 Which of these is super class of WindowEvent class ? A. WindowEvent B. ComponentEvent C. lemEvent D. InputBvent tine 20 6-0 Strat Met Qin Which ofthese is a renarn npe of gechdress method of D 4 DatagramPacker 2 Demgromsocit as 4) InecAddress D. SenerSooket 2 Inthe format for defining the URL what isthe last port? A. Protocol 2B File path teen CC Port number D. Hostname 3° Whats the first part of URL address ? A Host name B Port number Tos: 9) C File patk D. Protocol - ; ; ay of dota contained 4 Which of these methods of DatagramPactes is used 10 obiain the Byte arr ie a datagram ? A. getDatay B getdpres) C gettrrayy D. reveiveBytes() (ana. say Chapter 5 Q.1 Native - protocol pure Java converts __into the _ used by DBUSs direct. A. JDBC calls, network protocol BODBC: network protocol ©. ODBC class, user call D.JDBC cals, user call {ans 2) Q2 The JDBC-ODBC bridge driver resolves __and makes equivalent __ A. JDBC call, ODBC call B. ODBC call. ODBC call € ODBC call, JDBC call D. JDBC call, JDBC call as. 4} Q3° For execution of DELETE SQL query in JDBC._ method must be used. A. executeQuery) B. execureDelereQuery)) C exeewelpdarey D execueDelete) Teas sq) Q4 Prepared Statement objectin JDBC used to execute _ queries. A. Executable B Simple C High level D. Parameterized Tans.:0) Chapter 6 4 Name the class that includes the getSession() method that is used to get the HinpSession abject __. A. HipSenlerRequest 3. HipSerstetResponse €. SessionContext D.SessionConfig, ares] 2A user pes the URL hup:/>www.msbte com result php. Which HTTP request gets generated? Select the one correct answer __. A.GET method B.POST method C HEAD method D. PUT method as a} 23 Which ofthese is a protocol for breaking and sending packets to an address across a nenwork ? A TCIPAP B DNS Socket, D. Praxy Server a 4 tna web application running na webserver, whois responsible for creating request and response objec? A Web server B.Serviet ©. Container 2 Client po. T Teche Rbetane "= Ans br mocap Eee _ uation Paver wo je Programing 5-3 select Model Sse Lovel (2 Marks each) chapter 1 at hich components are used n the following output B. Applet, Label D. Grid Layout, Label, Button. contain title bar and MenuBars but it can have other components like A. Label, TextField, Button fans. : A} C. Applet, Button 2 — Which is the conlainer that doesn't button, texfield etc. ? A) Window ©) Panel 3 Name the class used to represent a GUI application title bar, an icon, and memus. B) Frame D) Container tans.) window, which is optionally resizable and can have a 4) Window B) Panel ©) Dialog D) Frame [Ans : Dy Q4 Which package provides many event classes and Listener interfaces for event handling ? A)javaawt B) java.awt.Graphics O)javacewtevent D) None of the above ee Chapter Ans. : C} Q1 What is the purpose of JTable ? A) Table object displays rows of data. B) JTable object displays columns of data. ©) STable object displays rows and columns of data. D) JTable object displays data in Tree form. Ans: 4} rT Teche Pars Ap ra ge hb — Solo! Medel Quan Aen se Ps 62 Which method used 0 cpa com om a component A) roltOvericon(Imagelcon ad 2) seticon(imagelcon ) ©) dspleyteonfimageleon D) removelcon (Imagelconi ) Chapter 3 4 Select she proper ouput for following code. importiava.awt.*? importiavaapplet. public class list2 extends Applet t public void int) t List I= new List2true); hadd(Yjava"): hadd("e+*"); Ladd("kek"); add); } 2 ‘/* "/ 4a (ans. 9) PY daca Toca Patcalans Ao op Pt or kowtedge Soloed Model Question Paper D Tans. :¢) Atorenl aa a2 ‘Select the missing statement in 8 import java.avt.": Inport yap applet code="mouse" wideh=300 height=1007 MouseMotionbistener */ public class mouse extends Applet < Sring msg ="": int mouseX = 0, mouseY=0: public void ini) f ¢ mouseX™ 0; smouseY = 10: ‘msg = "Mouse clicked.": repainig: implements MouseListene? } public void mouseClicked(MouseEvent me) , (public void mouseEntered(MouseEvert me) iseEvent me) } (public void mouseDragged(Mous é ‘mouseX=me.getx0; ‘mouseY=me getY( Solel Mode Question pene i Pr a3 i T S07 Saleed Model Question Poet eee anes ee repaint; oe t = showStarus("Moving mouse at "+ me.getX0 +", " + me.get¥Q); 1 ese votdpain(Graphes g) 1 arawSringinse. mowseX. mouse) } 4p addbouseMotionListener(h): B) addMouseListener(this) C) import java.awt.event. *; D)all of above Tans. : D} To get the following output complete the code given below, import java.awt.* import javax.swing.*; ” ” public class jscroll extends JApplet Technical Pubicaions” -An up thrust for knowledge Chapter 4 at az } yAR_ALWAYS: , 2 = SerllPaneConsants VERTICAL_SCROLLDY inch = SeroltPaneConsant NORIZONTAL SCROLLBAR ASNEBDED: “iserolPanesp = new JScrolPanedp.¥- ontentPane addjop, BorderLayou. CENTER): J ) ‘4 Container contentPane = getContentPane0: contentPane setLayout(new Gridcayout0) 8) JPanelip ~ new JPanel: Jjpsetbayout(new GridLayout(20, 20); Ointb=0: “for(int = 0: 1< 20:44) 1 Jortinsj = 0:)< 20:70 0 ‘pad new JButton("Button “+ )): +46; Dy SPanelip = new JPanel “psetlayout{new GridLayout(3,3): int b = 0: Sfortint i= 0:1 <3: 444) t Sor (int j= 0:) <3:5+4) f “pad (new JButton( "Button * + )): +4b: ‘Select the proper method fo retrieve the host name of local machine. “Aj static InetAddressgetLocalHost()throws UnknownHostException B) static netddressgetByName(String hostName)throws UnknownHastException O) static InetAddress{] getAllByName(String host wnHostExceptic Cee, ing hostname throws Unkno ‘ception Select the proper constructor of URL class A) URL{SEring protocolName String hostName, in _ Inport, String pl B) URL(Siring urlSpecifer) ©) URL(Siring protocolName, eae ‘Sring hostName, String path) {Ans. 0] {ins s4] Ans. =D) executeQuery) method returns ‘Ay Single row ©) Single Column PreparedStatement interface extends interface B) Statement D) Driver Ins. 8) B) ResultSet object D) Database Table fr) loz 4) Connection C) ResultSet chapter 6 Identify correct syntax of service() method of servlet class. 4) void service(ServletRequest req, ServetResponse res) 2) void service ServetResponse res ServletRequestreg,) 6) void service ServetRequesireg, ServetRequesirea) ‘D) void service ServetResponsereg, ServletResponse res) tans A} “Advantage of ISP over Servletis___- 1A) JSP is web page and servlets are Java programs 1) ISP is web page sriptng language and servlets are Java programs JSP is web page seriptng language and servlets are simple programs JSP is program and servlets are scripting language tans. 8] Apply Level (2 Marks each) Chapter 1 a1 Choose the correct sequence fo at a2 the following output. A) import java.awt import java.applet.*: public class app! extends Applet f public void init) : TextFieldtf = new TextField); “ecie Pbletons An prt x Komede (Checkbox cl'=new Checkbox("6" false) adda): adie): ade. diel): a “applet code=app class wideh=200 height=200> <“appler>* By import java.awe.*: ‘import java.applet.*: ‘public class appl extends Applet t Public void init ‘ TextPieldsf = new TextField): Textdrea tl =new Textdrea(3,20) Checkbox e=new Checkbax("a” true): Checkbox cl=new Checkbox("6" false): add(p); add{tl); add{e); addict); , Z /* */ ‘public class app| extends Applet é public void init) é TextField = new TextField); Textarea t!=new TextField): Checkbox c=new Checkbor("a" true); Checkbox cl=new Checkbox," false); add(ip); D)All of above Tectia Pubiaion Anup ta er kontdga Soloed Model Question ans, yor joa java.opple*: public lass LayoutDemo5 extends Applet f pote void tO inti knt veo BorderLayout(); Panel p!=new Panel(); ‘panel p2=new Panel; pisettayoutnen FlowbayeutO): phaddinew TextField(20)); plaadd(new TextField(20)); pa.setLayout(new GridLayout(5,3)): pradd(new Button("OK")); pradd(new Button("Submit")); ‘add(p1,BorderLayout.EAST); add{p2,BorderLayout. WEST): } fo code=LayoutDemo5.class width=300 height=400> * What will be the output of the above program? 1) Tre ouput is obtained in Frame with ov layouts: Frame layout and Flow Lavon 1) The output is obtained in Applet with to layouts: Frame layout and Flow Layout 9) The outpuis obtained in Applet with two layouts: Prame layout and Border Layout 1) The ouput is obtained in Applet with two layouts: Border layout and Flow Layout Tans.) Chapter 2 a4 Consider the following program. Find which statement contains error. import java.awt.*; import javax.swing.*; r ” public class JTableDemo extends JApplet é public void initO { ‘Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); w 0 Techaical Pubcaions~An up thrust for knawtedge az al Sing coleat = 1 emp Name", “me! nat Object] 08 = C Tpamesh 11%, SOE) 223", "92000" ("Sager Vira "333", "40000" mit’, "44", "62000" } [nit 58% "00000" = new STable(data) iat ants. VERTICAL. int h = SerollPaneConsiants ‘HORIZONTAL. sSeroliPoneisp = new JSerolPane( sable,» ‘ontentPane.addgsp, BorderLayant CENTER): } } “py Error n statement in which Table 8 created 1) Err in statment in which SSerolPane is created (© Error in statement in which applet a8 declared D) None of the above Sette proper command orn the flowin code import jaras.swing import java.applet.*; > ‘/ t public void init) t Container co = getContentPane0} co.setLayout(new FlowLayout0); IomboBoxjc=new SComboBax): jeaddltem(*cricket’); Jeadditem("football’): ‘jeaaddltem( hockey"); jeaaddltem( "tennis"): co.addgo); wz B)java A) Javac combodemo! java C)appletviewer combodemo! 1 java + width =300 height =100> SCROLLBAR_AS_NEEL SCROLLBAR. :DED: 2 AS NEEDED: ‘combodemol 1 D) All of above Techie Pabteaton ‘An ip tet nowtapo = ilies [Ans :AT [ans. 1 ace > sess proper code for given oatpat 4” peportjwaawe*? impor java.applet.*: pablic class choice! extends Applet pablic void init) Choice ox=new Choicel): os. add("wnn 8°); esadd(wnmap): os. add("wmant’); os.add("win 20007): addfos): - } ] 1 code="choice! I” height=200 width=300> */ B import java.awt.*: import jave.opplet. public class choice! extends Applet public void init) oe Progen t Choice os=new Choice): osadd("wnnt8"); osadé(wnmp"); ada(os)}} ‘/ */ ° ‘import java.awt import java.apple ‘Public class choicel extends Applet t public wid init t Choice os=new Choice; os.add{"win 2000"); add(os); } } D import java.avt: import java.applet.' Public class choicel I extends Applet € ‘public void init é Choice os=new Choice(); os.add(“wnn 18"); os.add(*wnnxp"); os.add("wnnnt"); os.add(“win 2000"); } i ‘/* */ Solel Motel Queston Paper es Tectnkal Pubkeatons ~ An up Prt nowedge ‘Select te: import java.awt. import java.aw.event. import javax.swing. r suis Solved Madel Question Paper missing statement in the program to get the following output “ < ” public class combodemo extends JApplet implements ItemListener t Slabel jl; Imagelcon france, germany, italy, japan; ‘public void int) t Container contentPane = getContentPane0) contentPane.setLayout(new FlowLayout)); IComboBox je = new JComboBox); Jeaddtiem(*France"); Jeaddttem("Germany’); Jeaddltem(taly’); jeaaddltem ("Japan") JeaddltemListener(this); contentPane.add(e); contentPane.add(i); Teta! Patna Anup Wat a kowadGe Aden fo Programing Chapter 4 a4 } public void itemStateChanged(lemEventic) t ‘Siring s = (Siringie getliem); Itsecon(new Imagelcon(s + "gif)): } , A) = new SLabel(new Imagelcon("star gif’): B)jl = new Mabel("tor gif): O)j1= new Habel{ Imagelcon(*star gif): D) None ofabove Consider the following program What will be displayed in the ouput ? Import java.net. *; class myAddress ‘ _publie static void main (String args{]) f ny t InetAddress address = InetAddress.getLocalHlost(); Spstem.out printin(address); A catch (UnknownHlostException e) f ‘System. out printin("Could not find this computer's address."); } } } A) The internet address of the server B) The internet address of the client ) The internet address of the host D) The internet address of any other PC Consider the following program What correction should be done in the program to get correct output ? import java.net.*; import java.io.*; public class URLTest { Techn! Pueaions An aa er nowedge Sola Moe! Quentin Paper ne. A) ans.) a2 Solved Model Question Peper pe ‘void main(String args[)) throws MalformedURLException { publics URL url _system.out.printin ‘Systemout printin( Port:"* wrll.getPort)): Systemout println("Host:" ur. gettfosiO): ‘System.outprintin("File:"+ url. getFileQ): B 1A) Exception type is wrong. £8) Class should not be public. ©) Creation of object isnot correct. (D) Use of ereated object not correct = new URL("http:/iwww.msbte.comidownload’); ("Protocol:"* urll.getProtocol0); ans. :D) chapter 5 at Consider the following program. What should be the correction done in the program to get correct output ? import java.sql.*; class Ddemol t public static void main(String args[]) throws. Exception a Class forName("sun, jdbc odbc.JdbcOdbeDriver'); Connection c=DriverManager.getConnection("jdbc:odbc:ODSN' ‘Statement s=c.createStatement0; ResultSet rs=s.executeQuery( "select from StudTable"); ‘System .out.printin(*Name" + "\t"+ "Roll No" + "\"+ "Avg"): while(rs.nexiQ) t ‘System. out println(rs.getString(1)+" \t "+rs.getint(2)+" \t "+s. getDouble(3)); s.close); cclose); } 2 A) Missing semicolon ©) Missing } B) Missing { D) Missing statement. nse] Tice tend” A ak nie i Seton Model Question Paper dean Joe Pr az Consider the following program. ‘What should be the correction done in the program to get correct output? import java.sal.; class Demo! { t (Class forNName("sun jdbe.odbe JdbcOubeDriver) ‘Connection c= DriverManager getConnection(dbe:odbe:ODSN' Statement s=c.createStatement): ResultSet rs=s.erecuteQuery(“select ‘from StudTable’); ‘System out printn(’Name" + "Wi" + "Roll No" + "\e "+ "Ave while(rs.mexiO) { ‘System out printin(rs getString(1)+" "+rs.getin((2)+" Wt \t"s.getDouble(3): nn loses closed} } 4) Missing semicolon 2B) Missing { © Missing } D) Missing statement. (ans: 0} Chapter 6 Quy ‘Choose missing statements in following code from given options. Public class session! extends HipServiet ¢ public void doGer(HipServietRequest request, HupServletResponse response) throwsServletException, IOException é HipSession hs = request getSession(irue); response.setContentType("texthim!"): Printl¥riter pw = response.gettriter): pwprint(""); Date date = (Date)hs.getAttribute( "date" ‘iidate != null) { Pwprint("Last access: " + date + "
"); } date = new Dated: As.setduribute("date", date); pw.printin(*Current date: "+ date); } } A) import java.io.*; import java.util 3) import java. Vector.* ; import java. Thread, rvlet hap. import javax servlet. *: import ave. : import javax.servlet.*: Teck Putcatone™ An ip tv eee ss Seto Mat Quen Per owas serie par joa Sin": port java Vector: ree ven paper ava Thread"; port fv Con": (09 Select ary ome option from given options } 'A) new Cookie MyCookie", data): B) new Cookie("MyCookie”, dasal); C) new Cookie("MyCookie”, data2): Dinew ie", database):

You might also like