CS506_Web Design and Development

Quiz no 02,  

16 Dec 2013

Which of the following approch is used to create threads in java?

Inheritance]

Interface

Both inheriance and interface (right Answer)

None of these

 

Why we use RequestDispatcher to forward a request to another resource(servlet, html, jsp), instead of using a sendRedirect()?

sendRedirect() is not supported in servlet API.

RequestDispatcher is not supported in servlet API.

RequestDispatcher is efficient and allows the server to maintain request status.

None of these (right Answer)

 

 

Which of the following method of an Applet is called every time when page is minimized?

start()

init()

stop()(right Answer)

destroy()

 

 

Which of the following statement is true regarding paintComponent() method?

It tells any components contained by this component to paint themselves.

It tells the component to paint its border.

It first paints the background and then performs custom painting. (right Answer)

It first performs custom painting and then paints the background.

 

 

 Which of the following is NOT true for an Applet?

A small program written in Java and included in a HTML page.  

It is independent of the operating system on which it runs.

They have no access to the client's file system. (right Answer)

An applet is a Panel that allows interaction with a Java program

 

 

Which of the following syntax is used to get DataBaseMetaData object?

 

ResultSetMetaData md = con.getMetaData();

// where con is Connection object

ResultSetMetaData md = rs.getMetaData();

// where rs is ResultSet object (right Answer)

ResultSetMetaData md = st.getMetaData();

// where st is Statement object

ResultSet md = rs.getMetaData();

// where rs is ResultSetMetaDta object

 

 

Why we use RequestDispatcher to forward a request to another resource(servlet, html, jsp), instead of using a sendRedirect()?

sendRedirect() is not supported in servlet API.

RequestDispatcher is not supported in servlet API.

RequestDispatcher is efficient and allows the server to maintain request status.

None of these (right Answer)

 

 

getColumnCount() is a method of ________ object.

Statement

ResultSet(right Answer)

ResultSetMetaData

DataBaseMetaData

 

doGet() and doPost() receive ServletRequest and ServletResponse objects as an arguments which facilitate interaction between the client and the server.

True (right Answer)

False

 

Which of the following method is used to move the cursor to given row number?

absolute(int);

absolute();

moveToInsertRow(int);

insertRow();

 

Which of the following method of an Applet is called every time when page is minimized?

start()

init()

stop()(right Answer)

destroy()

  

 

HTML form data can be processed by JSP
TRUE( right Answer)
FALSE

 

From the following methods, which method cannot be overridden in the JSP page

_jspService() (right Answer)
jspDestroy()
jspInit()
None of these

 

Which of the following object is used for sharing resources among different servlets of same application?
ServletConfig
ServletRequest
ServletResponse
Servlet Context  (right Answer)

getParameters() method returns an array of strings containing the values for a specified servlet parameter.
TRUE
FALSE(right Answer)

 

 

Socket is a ___________ communication channel between hosts.

uni-directional

bi-directional (right Answer)

multi-directional

None of these

 

 

setAttribute(String, Object) associates a ----------with a name.

None of these

Object

String

Value

Packages are the way to organize files into different -------------according to their functionality, usability as well as category they should belong to.

Directories (right Answer)

Folders

Libraries

None of these

 

When JSP page compiled, it is translated into?

Applet

Application

Servlet (right Answer)

Web Browser

 

From the following which ID is transmitted between the client and the server

Session ID (right Answer)

Network ID

Server ID

None of these

 

To define the error page in JSP we use following tag?

exception-type

error-type

error-page (right Answer)

exception-page

 

Which of the following is called Іpure abstract classІ?

Concrete Class  (right Answer)

Wrapper Class

Interface

Abstract class with no abstract method

 

The relationship between class and interface is called ____________

'Is a' relationship

'Has  a' relationship

'Responds to' relationship (right Answer)

None of the above given

 

Which of the following statement object is used to execute simple SQL statement?

Statement

PreparedStatement

CallableStatement

None of given (right Answer)

 

Which of the following function will be used to register even handler with events generators (button)?

addAction()

AddActionListener() (right Answer)

AddKListener()

ActionListener()

 

 

 

WindowsListener interface contains ___________ methods

Four

Six

Seven

Eight  (right Answer)

 

 

Java defines _____ for the listener interfaces having more than one vent handling methods.

Wrapper Classes

Abstract Classes

Concrete Classes

Adapter Classes  (right Answer)

 

Which of the following statement object is used to execute store procedures?

Statement

PreparedStatment

CallableStatement  (right Answer)

None of the above given

 

 

Which of the following object is passed as an argument to paintComponent() method?

Image object

Jpanel object  (right Answer)

JFrame onject

Graphic object

 

previous() is a method of __________ object.

Statement

ResultSet

ResultSetMetaData

Connection

 

Which of the following problem occurs with lower priority threads?

Race condition

Starvation (right Answer)

Average waiting time

Process death

 

Servlets are used to

Create graphics

Provide dynamic web contents which extend web servers  (right Answer)

Develop applets

Create GUI

 

 

Which of the following is NOT a part of HTTP request?

Request method

URI

Status code (right Answer)

Header fields

 

 

Which of the following object is used for sharing resources among different servlets of same application?

ServletConfig

ServletRequest

ServletResponse

ServletContext (right Answer)

 

 

Which of the following method needs to ovveride while handling threads in java?

init()

start()

run()(right Answer)

runnable()

 

 

Which of the following method is called only once during life cycle of Servlet

Service()

Init()(right Answer)

Destroy()

Start()

 

 

Which of the following method needs to override while handling threads in java?

Select correct option:

init()right Answer)

start()

run()

runnable()

 

 

isReadOnly() is a method of _________ object.

ResultSet

ResultSetMetaData

DataBaseMetaData

Connection

 

Which of the following syntax is used to get DataBaseMetaData object?

DataBaseMetaData md = rs.getMetaData();

// where rs is ResultSet object (right Answer)

DataBaseMetaData md = st.getMetaData();

// where st is Statement object

DataBaseMetaData md = con.getMetaData();

// where con is Connection object

DataBaseMetaData md = rsmd.getMetaData();

// where rsmd is ResultSetMetaData object

 

Interface of HttpServletResponse extends class ServletResponse

False

True  (right Answer)

 

Which of the following method is used to determine whether a database is read only or not?

isReadonly()

isReadOnly()

isreadonly()

IsReadOnly()

 

 

 

Servlet mapping is defined in ________

servlet

web.xml (right Answer)

html

JSP

 

Which of the following is NOT a web technoloy of Java?

Servlet

JSP

ASP

JSF (right Answer)

 

 

Which of the following is NOT true about HTTP?

HTTP is a stateless protocol

HTTP is a request response communication model

HTTP maintains user session between successive requests. (right Answer)

HTTP has no built-in state management between successive requests.

 

getrequest() method gets information from a client and postrequest() method posts data to a client.

True (right Answer)

False

 

 

 

getAttribute(String) extracts----------- stored value from a session object

Subsequently

None of these

Previously (right Answer)

Currently

 

getParameters() method returns an array of strings containing the values for a specified servlet parameter.

True

False (right Answer)

 

To destroy the session in Servlet we use?

session.destroy()

session.invalidate()

session.end()(right Answer)

session.Kill()

 

From the following which session tracking technique is used when new session is started?

Cookies

URL Rewriting

Both Cookies and URL Rewriting (right Answer)

None of these

 

HttpSession stores session information in

File system of client

File system of server

A cookie (right Answer)

A session object

 

HttpServletResponse object is created when web server executes the servlet. This object is passes to the servlet service method which passes it to doGet () or doPost().

True (right Answer)

False

Views: 7288

Replies to This Discussion

1 - What if the main method is declared as private?

1. The program does not compile

2. The program compiles but does not run

3. The program compiles and runs properly ( From Lectuer # 2)

4. The program throws an exception on compile time

 

2 - Java program code is compiled into form called

1. Machine code

2. native Code

3. Byte Code (From Lectuer # 2)

4. Source Code

 

3 - A top level class without any modifier is accessible to

1. any class

2. any class within the same package (From Lectuer # 4)

3. any class within the same file

4. any subclass of this class

 

4 - Overloading is _______ whereas overriding is _____

1. Run time binding, compile time binding

2. Late binding, compile time binding

3. Compile time binding, run time binding (From Lectuer # 4)

4. Run time binding, late time binding

 

5 - Static methods only access ___

1. instance variable

2. instance method

3. static variables and methods (From Lectuer # 4)

4. both static and instance members

 

6 - Which of the following is modifier is provided by default if no access is written explicitly?

1. public

2. Private

3. Protected

4. Default (From Lectuer # 4)

 

7 - A top level class may have only the following access modifier.

1. Package

2. Private

3. Protected

4. Public (From Lectuer # 4)

 

8 - Which of the following is used for inheritance in java?

1. implements

2. extends (From Lectuer # 5)

3. : (colon)

4. inherit

 

9 - A collection can store ..........

1. Homogenous objects (From Lectuer # 6)

2. Heterogeneous objects

3. Objects as well as primitive values

4. At most 100 objects

 

10 - Which of the following syntax is used to attach an input stream to console ?

1. FileReader fr = new FileReader(' input.txt ') ;  (From Lectuer # 7)

2. FileReader fr = new FileReader(FileDescriptor.in);

3. FileReader fr = new FileReader(FileDescriptor);

4. FileReader fr = new FileReader(console);

 

11 - Window frame and dialog use ________ as their default layout.

1. Border layout (From Lectuer # 7)

2. Flow layout

3. GridBag layout

4. Grid layout

 

12 - There are _________ types of exceptions in Java

1. 2

2. 3 (From Lectuer # 7)

3. 4

4. 5

 

13 - Which of the following belongs to a category of checked exception?

1. Null Pointer exception

2. IOException (From Lectuer # 7)

3. Array index out of bounds

4. NumberFormatException

 

14 - Which of the following exception belongs to a category of un-checked exception?

1. IOException

2. Null Pointer exception (From Lectuer # 7)

3. AWTException

4. ClassNotFoundException

 

15 - All the exceptions and errors in java are inherited from _____ class.

1. Exception

2. Error

3. Throwable  (From Lectuer # 7)

4. IOException

 

 

16 - Exceptions must be handled while handling files otherwise it may lead to _____

1. Logical error

2. Syntax error

3. Run-time error  (From Lectuer # 7)

4. No error

 

 

17 - Which of the following package needs to be import while handling files?

1. java.util

2. java.io   (From Lectuer # 7)

3. java.awt

4. javax.swing

 

18 - When defining a method you must include a/an ....... to declare any exception that might be thrown but is not caught in the method:

1. try block

2. finally block

3. catch block

4. throws clause  (From Lectuer # 7)

 

 

19 - The classes which contain the word _____ are byte oriented streams.

1. Reader

2. Writer

3. Stream  (From Lectuer # 8)

4. Byte

 

20 - Which of the following stream read/write data in the form of bytes?

1. FileReader

2. FileWriter

3. PrintWriter

4. FileInputStream  (From Lectuer # 8)

 

21 - An instance of abstract class cannot be created.

1. TRUE  (From Lectuer # 9)

2. FALSE

 

22 - Anabstractclass ---------------instantiated.

1. Cannot be (From Lectuer # 9)

2. Can be

3. Must

4. None of these

 

23 - The relationship between class and interface is called ________

1. ' Is a ' relationship  (From Lectuer # 9)

2. ' Has a ' relationship

3. ' Responds to ' relationship

4. None of the given options

 

 

24 - Which of the following is called ' pure abstract class ' ?

1. Concrete class

2. Wrapper class

3. Interface (From Lectuer # 9)

4. Abstract class with no abstract method

 

25 - Which of the following is called ' pure abstract class ' ?

1. Concrete class

2. Wrapper class

3. Interface (From Lectuer # 9)

4. Abstract class with no abstract method

 

26 - Which of the following is true about abstract class?

1. An abstract class must have all methods declared as abstract methods.

2. A class must have at least one abstract method to be an abstract class.

3. A class without any abstract method can be declared as abstract class. (From Lectuer # 9)

4. An instance of abstract class can be created.

 

27 - Which of the following stream is a filter stream?

1. FileWriter

2. FileReader

3. BufferedReader (From Lectuer # 9)

4. All of given options

 

28 - JPanel and Applet use ________ as their default layout.

1. Flow layout (From Lectuer # 10)

2. Border layout

3. Grid layout

4. GridBag layout

 

29 - Which of the following is true about AWT and SWING components?

1. AWT components creates a process whereas SWING component creates a thread. (From Lectuer # 10)

2. AWT components creates a thread whereas SWING component creates a

process.

3. Both AWT and SWING component creates a process.

4. Both AWT and SWING component creates a thread.

 

30 - BorderLayout is the default layout manager for a JFrame content pane

1. TRUE

2. FALSE (From Lectuer # 10)

 

31 - Which of the following is a general purpose container?

1. JFrame

2. Dialog

3. JPanel (From Lectuer # 10)

4. JApplet

 

32 - Border layout divides the area into _______ regions

1. 3

2. 4

3. 5 (From Lectuer # 10)

4. 6

 

33 - Which of the following function will be used to register event handler with events generator (button)?

1. addAction() 

2. addActionListener()     (From Lectuer # 11)

3. addListener()

4. registerListener()

 

34 - Event source can have --------- listeners registered on it.

1. Single

2. Double

3. Triple

4. Multiple (From Lectuer # 11)

 

35 - If a class needs to handle events generated by button then which of the following interface a class needs to implement?

1. ComponentListener

2. KeyListener

3. MouseListener

4. ActionListener   (From Lectuer # 11)

 

36 - Which of the following function is declared in MouseMotionListener interface?

1. public void mousePressed (MouseEvent me);

2. public void mouseDragged (MouseEvent me);   (From Lectuer # 12)

3. public void mouseClicked (MouseEvent me);

4. public void mouseEntered (MouseEvent me);

 

37 - WindowListener interface contains _______ methods.

1. Four

2. Six

3. Seven (From Lectuer # 12)

4. Eight

 

38 - Mouse events can be trapped for ________ GUI component.

1. JPanel

2. JFrame

3. JButton

4. All of given (From Lectuer # 12)

 

39 - Adapter classes have been defined for listener interfaces except ______ interface.

1. MouseListener

2. KeyListener

3. WindowListener

4. ActionListener (From Lectuer # 13)

 

40 - Which of the following package needs to import while interacting with relational database?

1. java.io

2. java.sql (From Lectuer # 14)

3. javax.swing

4. java.awt

 

41 - DSN stands for _________

1. Data System Name

2. Domain system Name

3. Data Source Name  (From Lectuer # 14)

4. Database System Name

 

42 - Which of the following method is used to execute SELECT SQL statements?

1. executeUpdate(sql);

2. ExecuteUpdate(sql);

3. executeQuery(sql); (From Lectuer # 14)

4. ExecuteQuery(sql);

 

43 - CREATE, ALTER, DROP are _________ SQL statements.

1. DML

2. DDL  (From Lectuer # 15)

3. DCL

4. None of given

 

44 - Which of the following method is used to execute INSERT, UPDATE and Delete SQL statements?

1. executeQuery(sql);

2. ExecuteQuery(sql);

3. executeUpdate(sql); (From Lectuer # 15)

4. ExecuteUpdate(sql);

 

45 - Which of the following statement object is used to execute stored procedures?

1. Statement

2. PreparedStatement

3. CallableStatement   (From Lectuer # 15)

4. None of given options

46 - HahMap takes key as a/an _________

1. Object  (From Lectuer # 16)

2. Array

3. Primitive value

4. Function

 

47 - To create DataBaseMetaData object we write following line of code

1. DataBaseMetaData db = con.getMeataData();  (From Lectuer # 17)

2. ResultSetMetaData rsmd = rs.getMetaData();

3. ResultSetMetaData rsmd = rs.setMetaData();

4. DataBaseMetaData db = con.setMeataData();

 

48 - A ................defines the way and method of communication between two parties

1. Compiler

2. Protocol  (From Lectuer # 17)

3. Tool

4. Technique

 

 

49 - Which of the following are passed as an argument to the paint () method:

1. A Canvas object-

2. A Graphics object-  (From Lectuer # 18)

3. An Image object-

4. A paint object-

 

50 - The code below draws a line. What color is the

line?g.setColor(Color.red.green.yellow.red);g.drawLine(0, 0, 100,100);

1. Red

2. Green

3. Yellow

4. Black  (From Lectuer # 18)

 

51 - Which of the following methods are invoked by the AWT to support paint and repaint

operations?

1. paint( )   (From Lectuer # 19)

2. repaint( )

3. draw( )

4. redraw( )

 

52 - If a super class method is protected then overriding method _________

1. must be protected

2. must be public  (From Lectuer # 20)

3. must be private

4. may be either protected or public

 

53 - Socket is a --------------communication channel between hosts.

1. Uni-directional

2. Bi-directional (From Lectuer # 21)

3. Multi-directional

4. None of these

 

54 - Aside from the Scanner class, which of the following class/es can be used for text file file input

1. ObjectInputStream (From Lectuer # 22)

2. BufferedReader

3. StringTokenizer

4. None of these

 

 

55 - You can ---------to a network using sockets.

1. Read

2. Write

3. Read/Write  (From Lectuer # 22)

4. None of these

 

56 - A serializable class must implement the method(s)............

1. readObject and writeObject

2. Either readObject or writeObject, or both, depending upon the desired behavior

3. No need to implement any method:   (From Lectuer # 22)

4. None of the given option

1. Which of the following is a general purpose container?

A. JFrame
B. Dialog
C. JPanel
D. JApplet


Applet, JFrame and Dialog are top level container.
2. Which of the following package needs to be import while handling files?
A. java.util
B. java.io
C. java.awt
D. javax.swing
3. Exception handling code is written in _______
A. try block ot confirm
B. catch block
C. finally block
D. throws clause

There are three blocks try , catch and exception.

Try block : codes normally used to generate error in this block.
catch block: codes used for exception handling in this block.
Final block: codes in this block always run irrespective of exception occur or not..
4. Which of the following stream is a Node stream?
A. PrintWriter
B. FileWriter
C. BufferedReader
D. All of given option

Node Stream: It is class of node which directly read or write to data source or sink. Like FileReader or FileWriter

BufferedReader and PrintWriter are the Filter Streams:

Filter Streams: Stays upon node stream and provide extra functionalities. It takes node streams as their input instead of direct source.

let me explain by Example:

FileWriter fw= null;
PrintWriter pw = null;

fw = new FileWriter (“myfilet.txt”); // reading directly myfile.txt
pw = new PrintWriter(fw); // see PrinterWriter is taking fw as input

BufferedReader act on fileReader stream so BufferedReader is also filter stream..
5. Which of the following stream read/write data in the form of bytes?
A. FileReader
B. FileWriter
C. PrintWriter
D. FileInputStream
6. Which of the following command is used to compile Java code?
A. java filename
B. javac filename.java
C. javac filename
D. java filename.java
7. Which of the following method is used to execute INSERT, UPDATE and Delete SQL statements?
A. executeQuery(sql);
B. ExecuteQuery(sql);
C. executeUpdate(sql);
D. ExecuteUpdate(sql);


executeQuery is used for normal select statements and executeUpdate is used for INSERT , DELETE or UPDATE statements.
8. Which of the following stream is a filter stream?
A. FileWriter
B. FileReader
C. BufferedReader
D. All of given options
9. An event in java is represented as ________
A. Operator
B. Function
C. Object
D. Primitive data type

An event in Java is represented as an object. When the user generates an event, the Java system creates an event object.
10. Which of the following belongs to a category of checked exception?
A. Null Pointer exception
B. IOException
C. Array index out of bounds
D. NumberFormatException
11. Packages are the way to organize files into different -------------according to their functionality, usability as well as category they should belong to.
A. Directories
B. Folders
C. Libraries
D. None of these

Packages are nothing more than the way we organize files into different directoritheir functionality, usability as well as category they should belong to.
12. When JSP page compiled, it is translated into?
A. Applet
B. Application
C. Servlet
D. Web Browser

Entire JSP page gets translated into a servlet (once), and servlet is what actually gets invok(for each request).

thnxxx good work

One more file download from given below link..

With the Lec Reference Solved Quizz...

Attachments:

Thanks u too..

Sadaf Rubab said:

thnxxx good work

RSS

Discussion Forum


7th Sem

CS 506 Assignment No.1 Solution Fall 2019

Started by Ayaan Khan.
Last reply
by Fakiha Nov 15, 2019. 1 Reply

CS506 Assign # 3 July, 2019

Started by + caмe4ѕтυdιeѕ.
Last reply
by + ! ! ! ! Hooriyaa ! ! ! ! + Jul 21, 2019. 3 Replies

CS506 Assign # 2 Due Date: 31st May, 2019

Started by + caмe4ѕтυdιeѕ.
Last reply
by + caмe4ѕтυdιeѕ May 27, 2019. 1 Reply

CS506 Assign # 1 Due Date: 16th May, 2019

Started by + caмe4ѕтυdιeѕ.
Last reply
by + caмe4ѕтυdιeѕ May 14, 2019. 3 Replies

Assignment # 02 of CS506 – Web Design and Development due date 31 January 2019

Started by + منشاء +.
Last reply
by +.ïɳnόϲϵᴎԎ ɖόІІ.+ Jan 30, 2019. 1 Reply

CS506 GDB Solution Spring 2018

Started by + ! ! Bɪʀʏᴀɴɪ.
Last reply
by + caмe4ѕтυdιeѕ Nov 6, 2018. 3 Replies

SPONSORED LINKS

© 2020   Created by Muhammad Anwar Tahseen.   Powered by

Badges  |  Report an Issue  |  Terms of Service