Nothing Special   »   [go: up one dir, main page]

0% found this document useful (0 votes)
345 views15 pages

Class Test - I Question Bank

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 15

Class Test – I

Question Bank
Advance Java Programming (AJP- 17625)
1) Which layout should you use to organize the components of a container in a tabular
form?
a) CardLayout
b) BorederLayout
c) FlowLayout
d) GridLayout
2. Which of these events is generated when a button is pressed?
a) ActionEvent
b) KeyEvent
c) WindowEvent
d) AdjustmentEvent
3) How do you change the current layout manager for a container?
a) Use the setLayout method
b) Once created you cannot change the current layout manager of a component
c) Use the setLayoutManager method
d) Use the updateLayout method
4. What does AWT stands for?
a) All Window Tools
b) All Writing Tools
c) Abstract Window Toolkit
d) Abstract Writing Toolkit
5) Which method will cause a Frame to be displayed?
a) show( )
b) setVisible( )
c) display( )
d) displayFrame( )
6) Which of the following creates a List with 5 visible items and multiple selection
enabled?
a) new List(5, true)
b) new List(true, 5)
c) new List(5, false)
d) new List(false,5)
7. Which of these package is used for graphical user interface?
a) java.applet
b) java.awt
c) java.awt.image
d) java.io
8. Which of these packages contains all the classes and methods required for even
handling in Java?
a) java.applet
b) java.awt
c) java.event
d) java.awt.event
9. Which of the following is the default Layout Manager for an Applet?
a) FlowLayout
b) BorderLayout
c) GridLayout
d) CardLayout
10. A checkbox is a control that consists of a
a. Combination of a small box
b. A label
c. Combination of a large box and a label
d. Both a & b
11. Arranges the components as a deck of cards such that only one component is
visible at a time
a. BorderLayout
b. CardLayout
c. GridLayout
d. FlowLayout
12. The Component class and MenuComponent class are the ___________ which
represent the GUI components.
a. Subclasses
b. Superclasses
c. Both a & b
d. None of these
13. The AWT classes can be roughly categorized into the following groups:
a. GUI Components
b. Layouts
c. Graphics Tools
d. Event Handlers
e. All of these
14. A menu bar represents
a. A list of menus which can be added to the top of a top-level window
b. A list of menus which can be deleted to the top of a top-level window
c. A list of menus which can be added to the bottom of a bottom-level window
d. None of these
15. Each menu is associated with a _________ list of menu items:
a. Checkbox
b. Drop-down
c. Choice
d. None of these
16. The two types of menus which are given as follows:
a. Pop-up menus
b. Regular menus
c. Both a & b
d. None of these
17. The text field and text area controls create a _________________ area respectively
a. Single-line text
b. Multi-line text
c. Both a & b
d. None of these
18. Given the following code
importjava.awt.*;
public class SetF extends Frame
{
public static void main(String argv[ ])
{
SetF s = new SetF();
s.setSize(300,200);
s.setVisible(true);
}
}
How could you set the frame surface color to pink.
A. s.setBackground(Color.pink);
B. s.setColor(PINK);
C. s.Background(pink);
D. s.color=Color.pink.
19. Suppose a Panel is added to a Frame and a Button is added to the Panel. If the
Frame's font is set to12-point TimesRoman, the Panel's font is set to 10-point
TimesRoman, and the Button's font is not set,what font will be used to dispaly the
Button's label?
A. 12-point TimesRoman.
B. 11-point TimesRoman.
C. 10-point TimesRoman.
D. 9-point TimesRoman.
20. Which of the following are true?
A. A Dialog can have a MenuBar.
B. MenuItem extends Menu.
C. A MenuItem can be added to a Menu.
D. A Dialog can be added to a Menu.
21. Which method is used to determine the class of an object?
A. getClass( ) method.
B. getObject( ) method.
C. getInet( ) method.
D. getVariable( ) method.
22. What Checkbox method allows you to tell if a Checkbox is checked?
A. getSize().
B. getStart().
C. getCheck().
D. getState().
23. Which object is needed to group Checkboxes to make them exclusive?
A. RadiobuttonGroup
B. CheckboxGroup
C. ControlGroup
D. GroupCheckbox
24. Name the class used to represent a GUI application window, which is optionally
resizable and can have a title bar, an icon, and menus. Select the one correct
answer.
a. Window
b. Panel
c. Dialog
d. Frame
25. What is the difference between a TextArea and a TextField?
A. A TextArea can handle multiple lines of text
B. A textarea can be used for output
C. TextArea is not a class
D. TextAreas are used for displaying graphics
26. In Graphics class Which method is used to set the graphics current color to the
specified color?
A) public abstract void setFont(Font font)
B) public abstract void setColor(Color c)
C) public abstract void drawString(String str, int x, int y)
D) None of the above
27. What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("http://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getLastModified);
}
}
Note: Host URL was last modified on june 18 tuesday2013 .
a) july
b) 18-6-2013
c) Tue 18 Jun 2013
d) Tue Jun 18 2013
28. What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws UnknownHostException
{
InetAddress obj1 = InetAddress.getByName("sanfoundary.com");
InetAddress obj2 = InetAddress.getByName("sanfoundary.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}
a) 0
b) 1
c) true
d) false
29. The web server then responds back to the _____________ accordingly:
a. Web browser
b. Web server
c. Server
d. All of these
30. _______protocol supports fast point to point datagram oriented model.
A. TCP/IP.
B. UDP.
C. TCP.
D. IP.
31. Which of the following properties are in BorderLayout?

A. alignment

B. hgap
C. layout

D. vgap

E. visible

32. Which of the following properties are in JFrame?

A. JMenuBar

B. title

C. iconImage

D. resizable

E. contentPane

33. To use no layout manager in a container c, use _________.

A. c.setLayout(NullLayout)

B. c.setLayout(null)

C. c.setLayout()

D. c.setLayout(new NullLayout())

34. _____ is used to receive input from the user.

A. An option dialog

B. A confirmation dialog

C. A message dialog

D. An input dialog

35. ________ is a low level routing protocol that breaks data into smaller packets.

A. Transmission control protocol.

B. Internet protocol.

C. File transfer protocol.

D. User datagram protocol.


36. __________are used to implement reliable, bidirectional, persistent point to point
stream basedconnection.

A. TCP/IP client socket.

B. FTP/IP client socket.

C. TCP/IP server socket.

D. FTP/IP server socket.

37. What is the first part of URL address?

A. Host name.

B. Port number.

C. File path.

D. Protocol.

38. In the format of URL what is the last part?

A. Protocol.

B. File path.

C. Port number.

D. Host name.

39. The URL connection classes are good enough for simple programs that want to
connect to ______server to fetch content.

A. FTP.

B. TCP.

C. HTTP.

D. UDP.

40. The constructor which is used to create client socket is ____________.

A. Socket(Inet Address, IP Address, int port).

B. ServerSocket(int port).
C. ServerSocket(int port, intmaxQueue).

D. Socket(Inet Address, int port).

41. _____________ are bundles of information passed between machines.

A. Datagrams.

B. Sockets.

C. Client Sockets.

D. Datagram packet.

42. The constructor which is used in server socket is______________.

A. Socket (Inet Address, int port, IP Address).

B. Server Socket (int port).

C. Server Socket (intmaxQueue, Inet Address).

D. Server Socket(intmaxQueue, Inet Address localAddress).

43. _______ method is used to examine the address and port information by the socket.

A. getInetAddress().

B. localPort().

C. getPort().

D. getLength().

44. To manage multiple client connections a server process must be -------------

A. multiported.

B. effective.

C. efficient.

45. Now a days we are using ----------- version of Internet addressing

A. IPV2.

B. IPV3.
C. IPV4.

D. IPV5.

46. If sockets have been invalidated ---------- are used to send and receive data.

A. IP stream.

B. TCP.

C. UDP.

D. I/O stream.

47. ________method returns the length of data contained in the byte array.

A. getLength().

B. getLengthOf().

C. getDataLength().

D. getDataLengthOf().

48. Which of these exception is thrown by URL class’s constructors?


a) URLNotFound
b) URLSourceNotFound
c) MalformedURLException
d) URLNotFoundException
49. Which of these methods is used to know host of an URL?
a) host()
b) getHost()
c) GetHost()
d) gethost()
50. Which of these methods is used to know the full URL of an URL object?
a) fullHost()
b) getHost()
c) ExternalForm()
d) toExternalForm()
51. Which of these class is used to encapsulate IP address and DNS?
a) DatagramPacket
b) URL
c) InetAddress
d) ContentHandler
52. What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws MalformedURLException {
URL obj = new URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getProtocol());
}
}

a) http
b) https
c) www
d) com
53. What is the output of this program?
import java.net.*;
class networking {
public static void main(String[] args) throws MalformedURLException {
URL obj = new URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getPort());
}
}
a) 1
b) 0
c) -1
d) garbage value
54. Select the missing statement in the program for following output

import java.awt.*;
public class MenuDemo extends Frame
{
public static void main(String args[])
{
MenuDemo m = new MenuDemo();
m.setVisible(true);
MenuBar mbr = new MenuBar();
m.setMenuBar(mbr);
Menu filemenu = new Menu("File");
Menu editmenu = new Menu("Edit");
Menu viewmenu = new Menu("View");
mbr.add(filemenu);
mbr.add(editmenu);
MenuItem new1 = new MenuItem("New");
MenuItem open1 = new MenuItem("Open");
filemenu.add(new1);
filemenu.add(open1);
}
}
A. mbr.add(view);
B. mbr.add(menu);
C. mbr.add(vieweditmenu);
D. mbr.add(viewmenu);
55. What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws MalformedURLException {
URL obj = new URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.toExternalForm());
}
}
a) sanfoundry
b) sanfoundry.com
c) www.sanfoundry.com
d) http://www.sanfoundry.com/javamcq
56. What is the output of the following program.
import java.net.*;
class URLDemo
{
public static void main(String args[]) throws MalformedURLException
{
URL netAddress= new URL("http://www.sun.com:8080/index.html");
System.out.println("Port :"+netAddress.getPort());
}}
A. 1
B. -1
C. 8080
D. None of the above
57. Select the proper output for following code
import java.awt.*;
import java.applet.*;
public class list2 extends Applet
{
public void init() {
List l= new List(2,true);
l.add("java");
l.add("c++");
l.add("kkk");
add(l);
}
} /*<applet code=list2.class height=200 width=200> </applet> */
a)

b)

c)
d)

58. Which components are used in the following output?

A. Label, TextField, Button


B. Applet, Label
C. Applet, Button
D. Grid Layout, Label, Button
59. Which of the following protocol provides reliable communication?
a. TCP
b. UDP
c. Both a & b
d. None of the above

You might also like