CLICK HERE FOR VARIOUS NEW JOBS 
CLICK HERE FOR VARIOUS EDUCATIONAL NEWS 
CLICK HERE FOR NEW SCHOLARSHIPS 
CLICK HERE FOR ADMISSION NOTICES 
Click And Follow On Google+ To Get Updates
Please Wait 10 Seconds... OR You CanSkip

ADMISSION NOTICES
Scholarships

Scholarship-300x291

BUDGET 2014-15
budget_2014-2015
New Date Sheets
VU SOLVED ASSIGNMENTS
Recent Posts

Posts Tagged ‘VU CS506 – Web Design and Development’

VU CS506 – Web Design and Development Midterm solved unsolved past papers 2012

VU CS506 – Web Design And Development Midterm Solved Unsolved Past Papers 2012

CS506- Web Design and Development

April 30,2012

Solved Subjective

From Midterm Papers

MC100401285 Moaaz.pk@gmail.com Mc100401285@gmail.com PSMD01

CS506 Midterm fall 2011 papers

1. Why we use serialization,2marks
Answer:- (Page 219)
Used to send an object to a stream
2. Differentiate between array and ArrayList . 2marks

Answer:- (Page 61)

 

It’s like a resizable array. ArrayList actually comes as a replacement the old “Vector” collection. As we add or remove elements into or from it, it grows or shrinks over time.

 

  1. 3.  Write the syntax to load the oracle driver . 2marks Answer:- (Page 152)

 

Class.forName(“oracle.jdbc.driver.OracleDriver”);

 

  1. 4.  What will happen if an image drawn out of the window coordinates? .  5 marks

 

5. How we process the results of sql query. 5 marks Answer:- (Page 153)

 

Process Results of the Query

v   The ResultSet provides various getXXX methods that takes a column index or name and returns the data

 

v   The ResultSet maintains the data in the form tables (rows & columns)

 

v   First row has index 1, not 0.

 

v   The next method of ResultSet returns true or false depending upon whether the next row is available (exist) or not and moves the cursor

 

v   Always remember to call next() method at-least once

 

v   To retrieve the data of the column of the current row you need to use the various getters provided by the ResultSet.

 

v   For example, the following code snippet will iterate over the whole ResultSet and illustrates the usage of getters

 

methods while ( rs.next() ){

 

//by using column name

String name = rs.getString(“columnName”);

 

// or by using column index String name = rs.getString(1);}

 

1

 

6. How a window handle its own events. 3marks Answer:- Click here for Detail

 

Using listeners is the preferred way of handling events since it is easier than enabling events directly for an object, and the code is clearer. Nonetheless, we should take a look at how you deal with events after calling enableEvents().

 

Diff b/w array n arraylist?   2marks

Answer:- rep

 

automatic reading in serialization?3marks Answer:- (Page 220)

System knows how to read data from stream and re-create object in memory.

 

The recreated object is type of “Object” therefore Down-casting is required to convert it into actual type.

 

GUI drivers?  3marks

Answer:- Click here for Detail

Java GUI Drivers

v   Several well-developed open-source tools

 

v   Some are more for unit testing GUIcomponents. Others are for system oracceptance testing.

 

v   Use various methods for triggering controls:

 

  • Use Robot to generate native OS events
  • Generate AWT events
  • Drive control components directly

 

What is advantage of collection over array?[2] Answer:- (Page 60)

 

Advantage of a collection over an array is that you don’t need to know the eventual size of the collection in order to add objects to it.

 

Which method of ResultSetMetaData objective is used to return the suggested value to column label for printout?[2]

 

Answer:- (Page 175)

The getColumnLabel() method returns the suggested column label for printouts

 

If a method is declared in protected where it can be accessible?[2]

Answer:-

It can be accessible to only to the class to which they belong, and any subclasses

 

What will happen if class implemented WindowListner interface and provided its definition of only one method? [3]

 

Answer:-

 

To handle window events, we need to implement “WindowListner” interface. To handle window events, we need to implement “WindowListner” interface.

 

“WindowListner” interface  contains 7 methods  We require only one i.e. windowClosing

 

2

 

But, We have to provide definitions of all methods to make our class a concrete class, if don’t do this we can not create its object.

 

State the name of the class with which Window like container can be declared for GUI and animation based Web application. And explain it. [3]

 

Write down the steps of make Client on Java Client Server application. [5] Answer:- (Page 175)

 

Steps – To Make a Simple Client

 

To make a client, process can be split into 5 steps. These are:

 

1. Import required package

 

You have to import two packages

. java.net.*;

. java.io.*;

 

2. Connect / Open a Socket with Server

 

Create a client socket (communication 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
The scheme is very similar to our home address and then phone number.
3. Get I/O Streams of Socket
Get input & output streams connected to your socket

.

For reading data from socket As stated above, a socket has input stream attached to it.
InputStream is = s.getInputStream();

 

// now to convert byte oriented stream into character oriented buffered reader // we use intermediary stream that helps in achieving above stated purpose

 

InputStreamReader isr= new InputStreamReader(is); BufferedReader br = new BufferedReader(isr);

 

.    For writing data to socket

 

A socket has also output stream attached to it. Therefore, OutputStream os = s.getOutputStream();

 

//   now to convert byte oriented stream into character oriented print writer

 

//   here we will not use any intermediary stream because PrintWriter constructor // directly

 

3

 

accepts an object of OutputStream PrintWriter pw = new PrintWriter(os, true);

 

Here notice that true is also passed to so that output buffer will flush.

 

4.   Send / Receive Message

 

Once you have the streams, sending or receiving messages isn’t a big task. It’s very much similar to the way you did with files

 

.    To send messages

.    To read messages

 

5.   Close Socket

 

pw.println(“hello world”);

String recMsg = br.readLine();

 

Don’t forget to close the socket, when you finished your work s.close();

 

What does it mean that a method or class is abstract? [5] Answer:- (Page 96)

 

Abstract classes are used to define only part of an implementation. Because, information is not complete therefore an abstract class cannot be instantiate. However, like regular classes, they can also contain instance variables and methods that are full implemented. The class that inherits from abstract class is responsible to provide details.

 

Any class with an abstract method (a method has no implementation similar to pure virtual function in C++) must be declared abstract, yet you can declare a class abstract that has no abstract method.

 

If subclass overrides all abstract methods of the super class, than it becomes a concrete (a class whose object can be instantiate) class otherwise we have to declare it as abstract or we can not compile it.

 

The most important aspect of abstract class is that reference of an abstract class can point to the object of concrete classes.

 

 

 

 

 

 

 

IDTERM EXAMINATION

Spring 2011

 

 

 

 

Q1:- WHY IS DIRECTLY PAINTCOMPONENT () METHOD NOT RECOMMENDED? Marks ( 2 ) Answer:- (Page 191 )

 

Painting is managed by system, so calling paintComponent() directly is not recommended at all. Similarly calling paint( ) method is also not recommended. Why? Because such code may be invoked at times when it is not appropriate to paint — for instance, before the component is visible or has access to a valid Graphics object.

 

 

 

4

 

Q2:-WRITE A DIFFERENCE BETWEEN EXECUTE QUERY SQL AND UPDATE QUERY SQL METHOD? Marks ( 2)

 

Answer:- (Page 152 ) executeQuery(sql) method

v   Used for SQL SELECT queries

 

v   Returns the ResultSET object that contains the results of the query and can be used to access the query

 

results.

String sql = “SELECT * from sometable”;ResultSet rs =stmt.executeQuery(sql);

 

executeUpdate(sql)method

v   This method is used for executing an update statement like INSERT, UPDATE or DELETE

 

v   Returns an integer value representing the number of rows updated

 

String sql = “INSERT INTO tablename ” + “(columnNames) Values (values)” ; int count = stmt.executeUpdate(sql);

 

Q3:- IS ITERATOR CLASS OR INTERFACE? WHAT IS ITS USE? Marks ( 2) Answer:- Click here for Detail

Iterator is an interface which is used to step through the elements of a Collection.

 

Q4:- DISCUSE THREE METHOD OF RESULTSET METADATA? Marks ( 3) Answer:- (Page 175)

 

Useful ResultSetMetaData methods

 

getColumnCount ( )

– Returns the number of columns in the result set

 

getColumnDisplaySize (int)

Returns the maximum width of the specified column in characters

 

getColumnType(int)

Returns the SQL type for the column to compare against types in java.sql.Types

 

Q5:-HOW GUI COMPONENT HANDLES ITS OWN EVENTS? Marks ( 3 ) Answer:- Click here for Detail

 

A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.

 

Q6:_ WHAT IS PORT? HOW CAN IT USEFULL IN NETWORK? Marks ( 5) Answer:- (Page 211)

It is a transport address to which processes can listen for connections request.

 

There are different protocols available to communicate such as TCP and UDP. We will use TCP for programming in this handout.

 

 

 

5

 

Q7:- WRITE FIVE TYPES OPERATORS USED IN SLECTION STATEMENT? Marks ( 5)

 

 

 

 

MIDTERM EXAMINATION

Spring 2011

 

 

 

how do we load a driver and how do we define a connection for URL and JDBC (5) Answer:- (Page 152 )

 

  1. 2.  Load Driver

Need to load suitable driver for underlying database.

 

v   Different drivers & types for different databases are available.

 

For MS Access, load following driver available with j2se.

 

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

 

For Oracle, load the following driver. You have to download it explicitly. Class.forName(“oracle.jdbc.driver.OracleDriver”);

 

Define Connection URL

 

To get a connection, we need to specify the URL of a database (Actually we need to specify the address of the database which is in the form of URL)

 

As we are using Microsoft Access database and we have loaded a JDBC-ODBC driver. Using JDBC-ODBC driver requires a DSN which we have created earlier and named it personDSN. So the URL of the database will be

 

What is the difference between Applet and Application (5) Answer:- Click here for Detail

 

Applets as previously described, are the small programs while applications are larger programs. Applets don’t have the main method while in an application execution starts with the main method. Applets can run in our browser’s window or in an appletviewer. To run the applet in an appletviewer will be an advantage for debugging. Applets are designed for the client site programming purpose while the applications don’t have such type of criteria.

 

Applet is the powerful tools because it covers half of the java language picture. Java applets are the best way of creating the programs in java. There are a less number of java programmers that have the hands on experience on java applications. This is not the deficiency of java applications but the global utilization of internet. It doesn’t mean that the java applications don’t have the place. Both (Applets and the java applications) have the same importance at their own places. Applications are also the platform independent as well as byte oriented just like the applets.

 

Applets are designed just for handling the client site problems. while the java applications are designed to work with the client as well as server. Applications are designed to exist in a secure area. While the applets are typically used.

 

6

 

Can an anonymous class be declared as implementing an inheritance and extending a class (3) Answer:- Click here for Detail

No. An anonymous class can extend a class or implement an interface, but it cannot be declared to do both

 

Difference between serialization and deserialization (3) Answer:- Click here for Detail

serialization – Turn data into a stream of bytes

 

deserialization – Turn a stream of bytes back into a copy of the original object.

 

Difference between character oriented and byte oriented streams (2) Answer:- Click here For Detail

 

Byte stream access the file byte by byte. A byte stream is suitable for any kind of file, however not quite appropriate for text files. For example, if the file is using a Unicode encoding and a character is represented with two bytes, the byte stream will treat these separately and you will need to do the conversion yourself. A character stream will read a file character by character. A character stream needs to be given the file’s encoding in order to work properly.

 

Why is executeUpdate() used (2)

Answer:- (Page 156)

Used to execute for INSERT, UPDATE, or DELETE SQL statements.

 

This method returns the number of rows that were affected in the database.

 

Name component subclasses that support painting (2)

Answer:- Click here for Detail

The Canvas, Frame, Panel, and Applet classes support painting.

 

 

MIDTERM EXAMINATION

Spring 2011

 

  1. 1.  Write Different between abstract class and interface class? 2 marks Answer:- Click here for Detail

 

Interfaces are essentially having all method prototypes no definition but Abstract class can contain method definitions also.

 

When the sub-types behavior is totally different then you use an interface, when the sub-types behavior is partially common and different with respect to the super type an abstract class is used.

 

  1. 2.  Write 4 types of JDBC Driver. 2 marks

Answer:- (Page 180)

Type – 1: JDBC – ODBC Bridge

 

Type 2: Native – API/partly Java driver

Type 3: Net – protocol/all–Java driver

 

Type 4: Native – protocol/all–Java driver

 

7

 

  1. 3.  If a method is declared as protected where can be the method accessed? 2 marks Answer:- (Page 41)

Accessible only to the class itself and to its subclasses or other classes in the same package.

 

  1. 4.  How can a GUI component handle its own events? 3 marks

Answer:- rep

 

  1. 5.  What Difference between serialization and de-serialization? 3 marks Answer:- rep

 

  1. How can we prevent serialization? 5 marks

 

Answer:- (Page 225 )

 

v Often there is no need to serialize sockets, streams & DB connections etc because they do no represent the state of object, rather connections to external resources

 

v To do so, transient keyword is used to mark a field that should not be serialized

 

v So we can mark them as,

o         transient Socket s;

o         transient OutputStream os;

 

  • transient Connecction con;

 

v Transient fields are returned as nullon reading

 

  1. 7.  Why do we use prepared Statement object? 5 marks Answer:- (Page 159 )

 

The PrepaeredStatement are used for executing precompiled SQL statements and passing in different

parameters to it.

 

v PreparedStatement object differs from Statement object as that it is used to create a statement in standard form that is sent to database for compilation, before actually being used.

 

v Each time you use it, you simply replace some of the marked parameters (?) using some setter methods.

v   We can create PreparedStatement object by using prepareStatementmethod of the connection class.

 

The SQL query is passed to this method as an argument as shown below.

 

PreparedStatement pStmt = con.prepareStatement (“UPDATE tableName SET columnName = ? ” + “WHERE columnName =?”);

 

 

Notices that we used marked parameters (?) in query. We will replace them later on by using various setter methods.

 

v If we want to replace first? With String value, we use setString method and to replace second? With int value, we use setInt method. This is shown in the following code snippet.

 

pStmt.setString (1 , stringValue); pStmt.setInt (2 , intValue)

 

8

 

 

MIDTERM EXAMINATION

Spring 2011

 

 

♣ 4 stages of applet cycles

Answer:- (Page 201 )

 

v   It can initialize itself.

v   It can start running.

 

v   It can stop running.

v   It can perform a final cleanup, in preparation for being unloaded

 

What will happen if a class implements Windowlistener Interface and it does not provide definitions of all methods.

 

Answer:- rep

 

♣  Methods to execute SQL query?

Answer:- rep

 

♣  What does mean by it if a class or method is abstract? (5 marks)

Answer:- rep

 

♣  Diff b/w Input/output streams class hierarchy and Read/Write class hierarchy?

Answer:-   Click here for Detail

 

The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

 

Basically there are 2 types of streams. Byte streams that are used to handle stream of bytes and character streams for handling streams of characters. In byte streams input/output streams are the abstract classes at the top of hierarchy, while writer/reader is abstract classes at the top of character streams hierarchy.

 

♣ Can applets communicate with each other? (5 marks) Answer:- Click here for Detail

 

Applets may communicate with other applets running in the same virtual machine. If the applets are of the same class, they can communicate via shared static variables. If the applets are of different classes, then each will need a reference to the same class with static variables. In any case the basic idea is to pass the information back and forth through a static variable.

 

An applet can also get references to all other applets on the same page using the getApplets() method of java.applet.AppletContext. Once you got a reference to an applet, you can communicate with it by using its public members.

 

 

9

 

♣ As a developer of GUI, what should u know about top level containers and general purpose

containers?

Answer:-   (Page 104 )

A container is a  collection of related  components, which allows other components to be nested inside it.

 

In application with JFrame, we attatch components to the content pane – a container.

 

Container are classified into two broad categories that are Top Level containers and General Purpose Containers

 

Top  level  containers  can  contain (add)  other containers as  well as  basic components (buttons,
labels  etc)  while  general  purpose containers are typically used to collect basic components  and are
added to top level containers.

 

General purpose containers cannot exist alone they must be added to top level containers

 

Examples of top level container are JFrame, Dialog and Applet etc. Our application uses one of these. Examples of general purpose container are JPanel, Toolbar and ScrollPane etc.

 

 

MIDTERM EXAMINATION

Spring 2011

 

 

 

What is the difference between a static and a non-static inner class? Answer: – Click here for Detail

 

A non-static inner class may have object instances that are associated with instances of the class’s outer class. A static inner class does not have any object instances.

 

What is the difference between Anonymous object and Named object? Give example with code. Answer:- (Page 146 )

 

We generally use anonymous object when there is just a one time use of a particular object but in case of a repeated use we generally used named objects and use that named reference to use that objects again and again.

 

 

 

Named

–   String s = “hello”; System.out.println(s);

 

–   “hello” has a named reference s.

 

Anonymous

–   System.out.println(“hello”);

 

Discuss any three methods of ResultSetMetaData?

Answer:-   rep

 

10

 

Two java collections. Which Should use for Your indexed Search?

Answer:-   Click here for Detail

Array List

 

Which Component subclasses are used for paint Answer:- Click here for Detail

‘Canvas’ is the subclass of Component that can be used for drawing and painting.

 

But generally Graphics class and its methods are used for drawing and painting. They are quite familiar with Java developers for drawing and painting. Canvas and Graphics have some common methods that are inherited from Component like paint(),update() etc. but Graphics class provides more facilities to a programmer with its methods.

 

 

Midterm Paper 2010

CS506-Web Design and Development

 

How do we create DataBaseMetaData object? (2) Answer:- (Page 177)

 

From a Connection object, a DataBaseMetaData object can be derived. The following code snippet demonstrates how to get DataBaseMetaDataobject.

 

Connection con= DriverManager.getConnection(url, usr, pwd);

DataBaseMetaData dbMetaData = con.getMeataData();

 

Write the syntax of update SQL Query. (2) Answer:- (Page 153 )

String sql = “INSERT INTO tablename ” + “(columnNames) Values (values)” ; int count = stmt.executeUpdate(sql);

 

What is the difference between the paint() and repaint() methods? (3) Answer:- (Page )

Answer:-   Click here for Detail

 

The paint method is where actual painting occurs. If you want to change the way a Component is drawn, you should override this method.

 

The repaint method typically just tells your Component that it should call its paint method as soon as it can. This is the method you should call to force a Component to update itself. The Java API warns not to ever directly call the paint method, mostly for efficiency reasons.

 

What interfaces needs to implement while handling ActionEvent, KeaEvent and WindowEvent? (3)

 

How can you retrieve data from the ResultSet? (5) Answer:- (Page 153)

 

The JdbcEx.java demonstrates the usage of all above explained steps. In this code example, we connect with the PersonInfo database, the one we have created earlier, and then execute the simple SQL SELECT query on Person table, and then process the query results.

 

11

 

What is difference between an Applet and an application? (5)

Answer:-   rep

 

 

MIDTERM EXAMINATION

Fall 2008

 

CS506- Web Design and Development (Session – 2)

 

Question No: 17   ( Marks: 1 )

 

What is the typical use of Hashtable? Answer:- Click here for Detail

 

Hash table is very important that time When a program wants to store a key value pair, one can use Hashtable.

 

Question No: 18   ( Marks: 1 )

Why we use paintChildern( ) method?

 

Answer:-   (Page 186)

Tells any components contained by this component to paint themselves

It is suggested that you do not override or invoke this method too.

 

Question No: 19   ( Marks: 2 )

Write any two steps of painting strategy.

 

Answer:-   (Page 187)

Subclass JPanel

Override the paintComponent(Graphics g) method

 

Question No: 20   ( Marks: 3 )

Name three paint () methods which are used to paint Swing Component.

 

Answer:-   (Page 186)

v   protected void paintComponent(Graphics g)

 

v   protected void paintBorder(Graphics g)

 

v   protected void paintChildren(Graphics g)

 

Question No: 21   ( Marks: 5 )

Differentiate between Named and Anonymous Objects.

 

Answer:-   rep

 

 

 

 

 

 

 

 

 

 

 

 

12

 

VU CS506 – Web Design And Development Midterm Solved Unsolved Past Papers 2012

VU CS506 – Web Design and Development Midterm solved unsolved past papers 2012

VU CS506 – Web Design And Development Midterm Solved Unsolved Past Papers 2012

CS506- Web Design and Development

April 28,2012

Solved MCQS

From Midterm Papers

MC100401285 Moaaz.pk@gmail.com Mc100401285@vu.edu.pk PSMD01

 

 

 

 

 

MIDTERM EXAMINATION

 

Spring 2010

CS506- Web Design and Development (Session – 3)

 

 

 

 

Question No: 1   ( Marks: 1 )   – Please choose one

If we remove static from main then program __________

►Program cannot compile

 

►Program will compile and work properly ►Run time errors

 

Exception throws in main      Click here for Detail

 

 

 

 

Question No: 2   ( Marks: 1 )   – Please choose one

If we remove String array from main then program____________

►Program cannot compile

 

►Program will compile and work properly Run time errors Click here for Detail ►Exception throws in main

 

 

 

Question No: 3 ( Marks: 1 ) – Please choose one Java developed in __________

►1990

 

1995  (Page 12)

 

►1997 ►2000

 

 

 

 

1

 

 

 

MIDTERM EXAMINATION

Fall 2008

CS506- Web Design and Development (Session – 2)

 

Question No: 1   ( Marks: 1 )   – Please choose one

Which of the following methods are invoked by the AWT to support paint and repaint operations?

 

►  paint( )    Click here for Detail

►  repaint( )

►  draw( )

►  redraw( )

 

Question No: 2   ( Marks: 1 )   – Please choose one

 

When defining a method you must include a ___________ to declare any exception that might be thrown but is not caught in the method.

 

►  try block

►  finally block

►  catch block

►  throws-clause      Click here for Detail

 

Question No: 3   ( Marks: 1 )   – Please choose one

Aside from the Scanner class, which of the following classes can be used for text-file file input?

 

►  ObjectInputStream

►  BufferedReader  Click here for detail

►  StringTokenizer

►  None of these

 

Question No: 4   ( Marks: 1 )   – Please choose one

Which of the following statements is true regarding Vectors with no specified base type?

 

►  A base type is needed, because Java needs to know how to allocate memory.

►  No base type is needed, because Java will use the Object class as a base type.  Click here for detail

►  If a base type is not specified the code will not compile.

►  No base type is needed because Vectors default to storing String objects.

 

Question No: 5   ( Marks: 1 )   – Please choose one

A serializable class must implement the method(s) _________.

 

►  readObject and writeObject

►  Either readObject or writeObject, or both, depending upon the desired behavior

► No need to implement any method    Click here for Detail

► None of the given option

 

 

2

 

Question No: 6   ( Marks: 1 )   – Please choose one

You can ———to a network using sockets.

 

►  Read

►  Write

 

► Read/Write    (Page 222)

► None of these

 

Question No: 7   ( Marks: 1 )   – Please choose one

Socket is a ————–communication channel between hosts.

 

► Uni-directional

 

► Bi-directional     (Page 211)

►  Multi-directional

►  None of these

 

Question No: 8   ( Marks: 1 )   – Please choose one

Which of the following are passed as an argument to the paint ( ) method?

 

► A Canvas object

► A Graphics object    Click here for detail

►  An Image object

►  A paint object

 

Question No: 9   ( Marks: 1 )   – Please choose one

 

The code below draws a line. What color is the line? g.setColor(Color.red.green.yellow.red); g.drawLine(0, 0, 100,100);

 

►  Red

►  Green

►  Yellow

 

►  Black

 

Question No: 10   ( Marks: 1 )   – Please choose one

To create DataBaseMetaData object we write following line of code

 

► DataBaseMetaData db = con.getMeataData();    (Page 177)

►  ResultSetMetaData rsmd = rs.getMetaData();

►  ResultSetMetaData rsmd = rs.setMetaData();

►  DataBaseMetaData db = con.setMeataData();

 

 

 

 

3

 

Question No: 11 (    Marks: 1 ) - Please choose one
Event source can have ——— listeners registered on it.
► Single
► Double
► Triple
► Multiple (Page 125)
Question No: 12 (    Marks: 1 ) - Please choose one
An abstract class ————— instantiated.
► Can’t be (Page 96)

►  Can be

 

►  Must

►  None of these

 

Question No: 13   ( Marks: 1 )   – Please choose one

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

 

► Compiler

 

► Protocol    (Page 242)

►  Tool

►  Technique

 

Question No: 14   ( Marks: 1 )   – Please choose one

What if the static modifier is removed from the signature of the main method?

 

►  The program does not compile

►  The program compiles but does not run

►  The program compiles and runs properly

The program throws an exception on compile time   Click here for Detail

 

Question No: 15   ( Marks: 1 )   – Please choose one

What if the main method is declared as private?

 

► The program does not compile…

 

► The program compiles but does not run   Click here for Detail

►  The program compiles and runs properly

 

►  The program throws an exception on compile time

 

Question No: 16   ( Marks: 1 )   – Please choose one

A member variable or method prefixed by the protected access modifier can be accessed:

 

►  Within the same class

►  Within the sub-class

►  Within the same package

► All of the above     Click here for Detail

 

4

 

 

MIDTERM EXAMINATION

Spring 2006

CS506- Web Design and Development

Question No: 1 ( Marks: 1 ) - Please choose one
In Java a final class must be sub-classed before it.
► True
False Click here for Detail
Question No: 2 ( Marks: 1 ) - Please choose one

 

A top level class without any modifier is accessible to ► any class

 

any class within the same package    Click here for Detail

►  any class within the same file

 

►  any subclass of this class

 

Question No: 3   ( Marks: 1 )   – Please choose one

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

►  Package

 

►  Private

 

►  Protected

 

►  Public Click here for Detail

 

Question No: 4 ( Marks: 1 ) - Please choose one
In Java an abstract class cannot be sub-classed
► True
False Click here For Detail
Question No: 5 ( Marks: 1 ) - Please choose one

Given a one dimensional array arr, what is the correct way of getting the number of elements in arr

►  arr.length Click here for Detail

 

►  arr.length – 1

 

►  arr.size – 1

 

►  arr.length()

 

Question No: 6   ( Marks: 1 )   – Please choose one

 

When recursive method is called to solve a problem, the method actually is capable of solving only the simpler case(s), or base case(s).

 

True

Click here For Detail

► False

5

 

 

Question No: 7   ( Marks: 1 )   – Please choose one

Which of these are valid declarations for the main method?

►  public void main();

 

►  public static void main(String args[]); (Page 26)

 

►  static public void main(String);

 

►  public static int main(String args[]);

 

 

Question No: 8   ( Marks: 1 )   – Please choose one

Map interface is derived from the Collection interface.

►  True

 

►  False Click here For Detail

 

Question No: 9   ( Marks: 1 )   – Please choose one

In Java, which of these classes implement the LayoutManager interface?

►  RowLayout

 

►  ColumnLayout

 

GridBagLayout    Click here for Detail

► FlowLayoutManager

 

Question No: 10   ( Marks: 1 )   – Please choose one

BorderLayout is the default layout manager for a JFrame’s content pane

 

True Click here For Detail ► False

 

 

 

 

 

MIDTERM EXAMINATION

Spring 2006

CS506- Web Design and Development (Session 1)

 

 

Question No: 1   ( Marks: 1 )   – Please choose one

 

You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?

►  public

 

►  private

 

►  protected

 

►  transient

 

default access               Click here For Detail

 

 

 

6

 

True
► False

Question No: 2   ( Marks: 1 )   – Please choose one

 

In Java garbage collection is done by_______________

 

JVM (Java Virtual Machine)   (Page 47)

►  Programmer

 

►  Both JVM (Java Virtual Machine)and Programmer

 

►  OS (Operating System)

 

►  None of given

 

Question No: 3   ( Marks: 1 )   – Please choose one

 

Which of following can be thrown using the throw statement?

►  Error

 

►  Throwable

 

►  Exception   (Page 72)

 

►  RuntimeException

 

►  All of Given

 

Question No: 4  ( Marks: 1 )   – Please choose one

 

____________is/are the JSP Implicit Object(s).

►  session

 

►  application

 

►  config

 

All of Given        Click here For Detail

► None of Given

 

Question No: 5   ( Marks: 1 )   – Please choose one

JavaBeans are?

►  A special Java class file

 

►  Servlets

 

►  Applets

 

A Special form of JSP    (Page 367)

► None of Given

 

Question No: 6   ( Marks: 1 )   – Please choose one

An expression tag contains a scripting language expression that is evaluated.

 

Click here For Detail

 

 

Question No: 7   ( Marks: 1 )   – Please choose one

A final class can’t be extended.

►  True Click here For Detail

 

►  False

 

 

7

 

Question No: 8   ( Marks: 1 )   – Please choose one

ServletConfig defines a set of methods that a servlet uses to communicate with its servlet container.

►  True

 

►  False Click here For Detail

 

Question No: 9   ( Marks: 1 )   – Please choose one

A method can not be made final until whole class is made final.

►  True

 

►  False

 

Question No: 10   ( Marks: 1 )   – Please choose one

Servlet session and JSP session have different abilities.

►  True

 

►  False Click here For Detail

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

8

 

 

CS506- Web Design and Development

 

Some other MCQ’s & quizzes

 

 

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

►The program does not compile

 

The program compiles but does not run   Click here for Detail  rep

►The program compiles and runs properly

 

►The program throws an exception on compile time

 

 

2 – Java program code is compiled into form called

 

►Machine code ►native Code

 

Byte Code       (Page 16)

►Source Code

 

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

►any class

 

any class within the same package   Click here For Detail

 

►any class within the same file ►any subclass of this class

 

4 – Overloading is _______ whereas overriding is _____

►  Run time binding, compile time binding

 

►  Late binding, compile time binding

 

►  Compile time binding, run time binding

 

►  Run time binding, late time binding

 

5 – Static methods only access ___

► instance variable

 

► instance method

 

static variables and methods    Click here For Detail

► both static and instance members

 

 

 

 

 

 

 

 

9

 

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

►  public

 

►  Private

 

►  Protected

 

Default              Click here For Detail

 

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

►  Package

 

►  Private

 

►  Protected

 

Public       Click here for Detail     rep

 

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

 

►implements ►extends

 

: (colon) Click here For Detail ► inherit

 

9 – A collection can store……….

►  Homogenous objects

 

►  Heterogeneous objects

 

►  Objects as well as primitive values

 

►  At most 100 objects

 

10 – Which of the following syntax is used to attach an input stream to console? FileReader fr = new FileReader(‘ input.txt ‘) ; (Page 77)

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

 

►  FileReader fr = new FileReader(FileDescriptor);

 

►  FileReader fr = new FileReader(console);

 

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

Border layout                 Click here For Detail

►  Flow layout

 

►  GridBag layout

 

►  Grid layout

 

12 – There are _________ types of exceptions in Java

►  2   (Page 72)

 

►  3

 

►  4

 

►  5

 

10

 

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

 

►  Null Pointer exception

 

►  IOException Click here For Detail

 

►  Array index out of bounds

 

►  NumberFormatException

 

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

 

► IOException

 

Null Pointer exception    Click here For Detail

►  AWTException

 

►  ClassNotFoundException

 

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

 

►  Exception

 

►  Error

 

►  Throwable Click here For Detail

 

►  IOException

 

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

 

►  Logical error

 

►  Syntax error

 

Run-time error    (Page 70)

► No error

 

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

 

►  java.util

 

►  java.io   Click here For Detail

 

►  java.awt

 

►  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:

 

► try block

 

► finally block

 

► catch block

 

throws clause              Click here For Detail

 

11

 

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

 

►  Reader

 

►  Writer

 

►  Stream   (Page 87)

 

►  Byte

 

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

 

►  FileReader

 

►  FileWriter

 

►  PrintWriter

 

►  FileInputStream   (Page 87)

 

21 – An instance of abstract class cannot be created.

►  TRUE Click here For Detail

 

►  FALSE

 

22 – An abstract class —————instantiated.

 

►  Cannot be Click here For Detail

 

►  Can be

 

►  Must

 

►  None of these

 

23 – The relationship between class and interface is called ________

 

‘ Is a ‘ relationship   (Page 98)

►  ‘ Has a ‘ relationship

 

►  ‘ Responds to ‘ relationship

 

►  None of the given options

 

24 – Which of the following is called ‘ pure abstract class ‘ ?

►  Concrete class

 

►  Wrapper class

 

Interface   (Page 98)

► Abstract class with no abstract method

 

25 – Which of the following is called ‘ pure abstract class ‘ ?

►  Concrete class

 

►  Wrapper class

 

Interface   (Page 98) rep

► Abstract class with no abstract method

 

12

 

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

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

 

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

 

►  A class without any abstract method can be declared as abstract class.   Click here for detail

 

►  An instance of abstract class can be created.

 

 

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

►  FileWriter

 

►  FileReader

 

►  BufferedReader   (Page 91)

 

►  All of given options

 

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

►  Flow layout Click here for detail

 

►  Border layout

 

►  Grid layout

 

►  GridBag layout

 

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

►  AWT components create a process whereas SWING component creates a thread.

 

►  AWT components create a thread whereas SWING component creates a process.

 

►  Both AWT and SWING component creates a process.

 

►  Both AWT and SWING component creates a thread.

 

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

►  TRUE Click here For Detail

 

►  FALSE

 

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

► JFrame

 

► Dialog

► JPanel      Click Here For Detail

 

► JApplet

 

32 - Border layout divides the area into _______ regions

►  3

 

►  4

 

►  5 (Page 113)

 

►  6

 

 

 

13

 

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

 

► addAction()

 

addActionListener()    (Page 123)

►  addListener()

 

►  registerListener()

 

34 – Event source can have ——— listeners registered on it.

 

►  Single

 

►  Double

 

►  Triple

 

Multiple    (Page 125)

 

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

 

►  ComponentListener

 

►  KeyListener

 

►  MouseListener

 

►  ActionListener   (Page 122)

 

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

 

► public void mousePressed (MouseEvent me);

 

public void mouseDragged (MouseEvent me);    (Page 130)

► public void mouseClicked (MouseEvent me);

 

► public void mouseEntered (MouseEvent me);

 

37 – Window Listener interface contains _______ methods.

► Four

 

► Six

 

Seven    (Page 133)

► Eight

 

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

►  JPanel

 

►  JFrame

 

►  JButton

 

All of given    (Page 130)

 

14

 

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

►  MouseListener

 

►  KeyListener

 

►  WindowListener

 

►  ActionListener Click here For Detail

 

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

► java.io

 

java.sql   (Page 149)

►  javax.swing

 

►  java.awt

 

41 – DSN stands for _________

►  Data System Name

 

►  Domain system Name

 

Data Source Name Click here For Detail ► Database System Name

 

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

►  executeUpdate(sql);

 

►  ExecuteUpdate(sql);

 

executeQuery(sql);    (Page 154)

► ExecuteQuery(sql);

 

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

► DML

 

DDL   (Page 156)

►  DCL

 

►  None of given

 

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

► executeQuery(sql);

► ExecuteQuery(sql);

 

executeUpdate(sql);     (Page 153)

► ExecuteUpdate(sql);

 

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

► Statement

► PreparedStatement

 

CallableStatement    (Page 159)

► None of given options

 

15

 

46 – HahMap takes key as a/an _________

 

►  Object   (Page 62)

 

►  Array

 

►  Primitive value

 

►  Function

 

47 – To create DataBaseMetaData object we write following line of code DataBaseMetaData db = con.getMeataData(); (Page 177)

►  ResultSetMetaData rsmd = rs.getMetaData();

 

►  ResultSetMetaData rsmd = rs.setMetaData();

 

►  DataBaseMetaData db = con.setMeataData();

 

 

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

 

►  Compiler

 

►  Protocol   (Page 242)

 

►  Tool

 

►  Technique

 

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

 

► A Canvas object-

 

A Graphics object-   Click here for detail

►  An Image object-

 

►  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);

►  Red

 

►  Green

 

►  Yellow

 

►  Black

 

51 – Which of the following methods are invoked by the AWT to support paint and repaint operations?

 

►  paint( )   Click here For Detail

 

►  repaint( )

 

►  draw( )

 

►  redraw( )

 

 

16

 

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

►  must be protected

 

►  must be public Click here For Detail

 

►  must be private

 

►  may be either protected or public

 

53 – Socket is a ————–communication channel between hosts.

► Uni-directional

 

Bi-directional    (Page 211)

►  Multi-directional

 

►  None of these

 

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

► ObjectInputStream

 

BufferedReader      Click here for detail

►  StringTokenizer

 

►  None of these

 

55 – You can ———to a network using sockets.

► Read

 

► Write

 

Read/Write    (Page 222)

► None of these

 

56 – A serializable class must implement the method(s)…………

►  readObject and writeObject

 

►  Either readObject or writeObject, or both, depending upon the desired behavior

 

►  No need to implement any method:   Click here For Detail

 

►  None of the given option

 

 

CS506- Web Design and Development

 

Some other MCQ ’s & quizzes

 

Question # 1 of 10

Which of the following feature provide facility for multiple inheritances:-

►  Adapter Classes

 

►  Wrapper Classes

 

►  Interface Click here For Detail

 

►  Collection

 

 

17

 

Question # 2 of 10

The relationship between class and interface is called ________

 

‘Is a’ relationship      (Page 98) rep

►  ‘Has a’ relationship

 

►  ‘Responds to’ relationship

 

►  None of the given options

 

Question # 3 of 10

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

►  addAction()

 

►  addListener()

 

addActionListener()   (Page 123) rep

► Register eventhandeler()

 

Question # 4 of 10

The collections API are defined in ______ package?

► Java.io

► Java.util

 

Java.sql    (Page 180)

► Java.awt

 

Question # 5 of 10

Which of the following is true about abstract class?

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

 

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

 

A class without any abstract method can be declared as abstract class.  Click here for detail   rep

► An instance of abstract class can be created.

 

Question # 6 of 10

Exceptions must be handled while handling files otherwise it may lead to____?

►   Logical error

 

►  Syntax error

 

►  No error

 

Run time error   (Page 70) rep

 

Question # 7 of 10

Which of the following stream is a filter stream?

BufferedReader     (Page 91) rep

►  FileWriter

 

►  FileReader

 

►  All of given options

 

 

18

 

Question # 8 of 10

CREATE, ALTER, DROP are _________ SQL statements.

► DML

 

DDL    (Page 156) rep

►  DCL

 

►  None of above

 

Question # 9 of 10

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

►  Statement

 

►  PreparedStatement

 

CallableStatement   (Page 159) rep

► None of given options

 

Question # 10 of 10

Based on functionality, the streams can be categorized as________

►  Byte oriented streams and Node Streams

 

►  Filter stream and Character oriented stream

 

Node stream and Filter stream      Click here for detail

► Byte oriented stream and Character oriented stream

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

19

 

VU CS506 – Web Design And Development Midterm Solved Unsolved Past Papers 2012

ALL NEW RESULTS
Educational News

Updated Educational News

Categories
POSTS BY DATE
December 2016
M T W T F S S
« Sep    
 1234
567891011
12131415161718
19202122232425
262728293031