Thursday , 21 November 2024

CS506 Unsolved Paper for Final Term Try to solve

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

Question No: 3

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

► ObjectInputStream
► BufferedReader {its correct answer}
► 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.
► 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
► None of the given option

Question No: 6 ( Marks: 1 ) – Please choose one
You can ———to a network using sockets.
► Read
► Write
► Read/Write
► None of these

Question No: 7 ( Marks: 1 ) – Please choose one
Socket is a ————–communication channel between hosts.
► Uni-directional
► Bi-directional
► Multi-directional
► None of these

Question No: 8

( Marks: 1 )

– Please choose one

( Marks: 1 )

– Please choose one

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

► A Canvas object
► A Graphics object
► An Image object
► A paint object

Question No: 9

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 not sure!!!

Question No: 10 ( Marks: 1 ) – Please choose one
To create DataBaseMetaData object we write following line of code
► DataBaseMetaData db = con.getMeataData();
► ResultSetMetaData rsmd = rs.getMetaData();
► ResultSetMetaData rsmd = rs.setMetaData();
► DataBaseMetaData db = con.setMeataData();

Question No: 11 ( Marks: 1 ) – Please choose one
Event source can have ——— listeners registered on it.
► Single
► Double
► Triple
► Multiple

Question No: 12 ( Marks: 1 ) – Please choose one
An abstract class ————— instantiated.

► Can’t be
► 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.

( Marks: 1 )

– Please choose one

► Compiler
► Protocol
► 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 [correct]

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
► The program compiles and runs properly
► The program throws an exception on compile time [correct}

Question No: 16

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

Question No: 17

What is the typical use of Hashtable?

To store the elements in the (key , value) pair

wrong

( Marks: 1 )

– Please choose one

( Marks: 1 )

Question No: 18 ( Marks: 1 )
Why we use paintChildern( ) method?
To paint the children of the object if any,,,, this method is implicitly called by
the compiler itself and we don’t need to override it… for example if we have some
buttons in a frame than to paint the childrens(buttons )this method will be used!!
Question No: 19 ( Marks: 2 )
Write any two steps of painting strategy.

First extends ur class from JPanel and secondly override the paintComponent
method!!!

Question No: 20 ( Marks: 3 )
Name three paint () methods which are used to paint Swing Component.

Repaint(),,,, setColor,,,,, setSize

Question No: 21 ( Marks: 5 )
Differentiate between Named and Anonymous Objects.

Named objects are those who are used throught references,,,as
String s = “pak” here pak is used with the reference s…

And anonymous objects are those which are used without reference(directly used)
As we often used like this


System.out.println(“pak”);
Here we are using string pak without any reference

Question No: 22 ( Marks: 10 )
Following are the contents of file1.txt

My name is ali.
My roll no is bc020400001.
I am studying java.
Java is very easy.

You are required to write a code which will read this file and create a new file in
which lines would be swapped in such a way that first line would be swapped with
2nd and 3rd with 4th and so on.

New file should look like:

My roll no is bc020400001.
My name is ali.
Java is very easy.
I am studying java.

(5 Marks file handling, 5 Marks swapping)

 

Paper 2

 

Total Marks=85
1. Name any two layers of web application?
2Marks
2. How to track a user session in servlets?
2Marks
3. Why do we use client side validation?
2Marks
4. What is the difference between static and non-static variables?
2Marks
5. How JSP pages are informed about the error page?
2Marks
6. Write any four Thread state?
3Marks
7. What are the benefits of using package? Explain with an example.
3Marks
8. What impact a javaBean object can produce when is stored in an application?

3 Marks
9. In which situation we can use Express Language?
3Marks
10. If a Java programmer doesn’t use layout mangers then what difficulties would be
face when creating Graphical User Interface?
5 Marks
11. What are the types of JSP Elements?
5Marks
12. What are the two ways to initialization parameter of a servlet?
5Marks
13. Which has responsibility for the propagation of multicast routing? Explain it with
example.
5Marks

Check Also

CS101 100% Solved MCQS for Final term Papers by Arslan Ali

CS101 105 Important MCQ’s Solved   Question No: 1    ( Marks: 1 )    – Please …

Leave a Reply

Your email address will not be published. Required fields are marked *

*