CS506 MIDTERM SOLVED MCQS by JUNAID
CS506 MIDTERM SOLVED MCQS by JUNAID
CS506 MIDTERM SOLVED MCQS by JUNAID
Developing
MID TERM MCQS
Prepared by: JUNAID MALIK
AL-JUNAID TECH INSTITUTE
1. Which of the following feature provides the facility for multiple inheritance?
a. Adapter classes
b. Wrapper classes
c. Interfaces Page No 95
d. Collections
2. setColor() is a method of _ object.
a. JPanel
b. JFrame
c. Graphics page No 175
d. Image
3. If we want to animate something like ball, moving from one place to another.
we constantly need to call paint () method.
a. True
b. False Page NO 176
4. If we want to call toString() method of parent class in JAVA. Which of the
following statement will be used?
a. this. toString();
b. new. toString();
c. sub. toString();
d. super.toString(); p page NO 57
5. Which of the following syntax is used to create a client socket?
a. Socket s = new Socket(“serverName”);
b. Socket s = new Socket(serverport);
c. Socket s = new Socket(“serverName”, serverPort); page No 195
d. Socket s = new Socket(serverPort, “serverName”);
6. In order to include graphics in your Java program, it is mandatory to extend
from class.
a. JLabel
b. JFrame
c. JPanel page 174
d. JButton
AL-JUNAID TECH INSTITUTE
7. What will happen if static modifier is removed from the signature of main
method?
a. The program does not compile
b. The program compiles and runs successfully
c. The program compiles but does not run Google
d. None of given options
a. it is object oriented
b. it uses built in libraries page 4 HO
c. it does not use pointers
d. it checks all errors, malicious and viruses
254. Which of the given Listener Interfaces is needed to handle the
“MouseEvent”?
a. MouseListener page 105 HO
b. MouseMotionListener
c. MouseActionListener
d. MouseFocusListener
255. In Java, Transient fields are returned as null on reading.
a. True page 208 HO
b. False
256. Which of the given Listener Interfaces is need to handle the “KeyEvent"?
a. MouseKeyListener
b. MotionKeyListener
c. KeyListener Page 105 HO
d. KeyActionListener
257. An applet is a JFrame that allows interaction with a Java program.
a. True
b. False Page 181 HO
258. Given code is showing the result of addition of two integer type numbers.
Choose correct output of this code.
Int i = 7; int j = 8; int k = i+j;
AL-JUNAID TECH INSTITUTE
System.out.printIn(“Seven” + i + “plus Eight” + j + “is” + k);
a. Seven 7 plus Eight 8 is 15
b. Seven i plus Eight j is k
c. Seven i plus Eight j is +15
d. Seven plus Eight is k
259. An applet is typically embedded in a Web page and can be run from a
browser.
a. True Page 181 HO
b. False
260. In Java, we can read/write to a network using sockets.
a. True
b. False page 206 HO
261. Which of the following statements attaches an output stream to console?
a. FileWriter fw = new FileWriter(“output.txt”); Page 80 HO
b. FileWriter fw = new FileWriter(FileDescriptor.out);
c. FileWriter fw = new FileWriter(FileDescriptor.in);
d. FileWriter fw = new FileWriter(FileDescriptor);
262. In java, adapter classes have been defined for the following listener
interfaces except interface
a. FocusListener
b. ComponentListener
c. MouseMotionListener
d. ItemListener Page 119 HO
263. In Java Graphics, while painting a swing component. which of the following
functions is invoked first?
a. Paint()
b. paintComponent() Page 169 HO
c. paintBorder()
d. PaintChildern()
264. If the subclass overrides all the abstract methods of super class, then
subclass is called _.
a. Abstract class
b. Concrete class Page 83 HO
c. Base class
d. Parent class
AL-JUNAID TECH INSTITUTE
265. Which of the following command is used to invoke an Applet from
command line interpreter?
a. Applet htmlfile
b. appletviewer htmlfile page 183 HO
c. appletviewer javafile
d. viewer htmlfile
266. The classes which contain the word _in their names are byte oriented
streams.
a. Reader
b. Writer
c. Stream Page 71 HO
d. Byte
267. Which of the following syntax is used to get DataBaseMetaData object?
a. DataBaseMetaData md = rs.getMetaData();
// where rs is ResultSet object
b. DataBaseMetaData md = st.getMetaData();
// where st is Statement object
c. DataBaseMetaData md = con.getMetaData();
// where con is Connection object Page 160 HO
d. DataBaseMetaData md = rsmd_.getMetaData();
// where rsmd is ResultSetMetaData object
268. In the context of Java Graphics; most of time, painting is done
automatically.
a. True Page 165 HO
b. False
269. How many ports are available for UDP socket?
a. 64
b. 128
c. 64k page 193 HO
d. 128k
270. is the correct syntax to set size of top-level container
“myFrame” as 200 rows in pixel and 400 columns in pixel.
a. myFrame.setSize(200,400) ;
b. myFrame.setSize(400,200) ;
c. myFrame->setSize(200,400) ;
d. myFrame->setSize(400,200) ;
AL-JUNAID TECH INSTITUTE
271. int i = (int)( Math.random() * 5 ); // will generate random numbers between
.
a. 0 & 4 page 187 HO
b. 0 & 5
c. 1 & 4
d. 1 & 5
272. If you want the timer to fire only the first time and then stop, invoke
.
a. setRepeats(false) Concept
b. setRepeats(true)
c. setOnce(false)
d. setOnce(true)
273. In ResultSetMetaData methods, method returns the
suggested column label for printouts.
a. getColumnName()
b. getColumnCount ()
c. getColumnType (int)
d. getColumnLabel() Page 157
274. Which of the following method/s is a ResultSetMetaData method?
a. All of the given options Page 157
b. getColumnCount ()
c. getColumnName(int)
d. getColumnDisplaySize (int)
275. Which of the following method is used to release the JDBC and database
resources in ResultSet?
a. next()
b. getters
c. previous()
d. close() Page 144
276. Which of the following is the correct way to access writeObject() function
using “out” object of ObjectOutputStream class.
a. out->writeObject()
b. out<-writeObject()
c. out->(.writObject())
d. out.writObject() Page 204
AL-JUNAID TECH INSTITUTE
277. In ResultSetMetaData methods, method returns the number of
columns in the result set.
a. getColumnCount ( ) Page 157
b. getColumnDisplaySize (int)
c. getColumnLabel (int)
d. getColumnType (int)
278. By implementing this interface, a class declares that it is willing to be
by automatic serialization machinery.
a. Checked
b. Decode
c. Read Page 203
d. Destroyed
279. The method returns true or false depending upon whether the
next row is available (exist) or not in ResultSet.
a. getters
b. next() Page 134
c. close()
d. close()
280. In ResultSetMetaData methods, _ method returns the SQL type
for the column to compare against types in java.sql Types
a. getColumn Type (int) Page 157
b. getColumnCount()
c. getColumnName(int)
d. getColumnDisplay Size (int)