Sanfoundry

Ace your homework & exams now with Quizwiz!

What does URL stands for? a) Uniform Resource Locator b) Uniform Resource Latch c) Universal Resource Locator d) Universal Resource Latch

a

What is a Graphics object? a. The Graphics object represents the part of the Frame that you can draw on. b. The Graphics object represents the whole Frame. c. The Graphics object represents the entire monitor. d. The Graphics object represents the graphics board.

a

What is it called when a program is written to respond to the button clicks, menu selections, and other actions of the user in whatever order the user does them? a. Event-driven programming. b. Action-driven programming. c. User-driven programming. d. Mouse-driven programming

a

What is the one component that nearly all GUI programs will have? a. Frame b. Mouse c. Monitor d. Button

a

What is the output of this program? class newthread implements Runnable { Thread t; newthread() { t = new Thread(this,"My Thread"); t.start(); } public void run() { System.out.println(t.getName()); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } } a) My Thread b) Thread[My Thread,5,main] c) Compilation Error d) Runtime Error

a

Which of these Exceptions is thrown by remote method? a) RemoteException b) InputOutputException c) RemoteAccessException d) RemoteInputOutputException

a

Which of these interface is implemented by Thread class? a) Runnable b) Connections c) Set d) MapConnections

a

Which of these is a protocol for breaking and sending packets to an address across a network? a) TCIP/IP b) DNS c) Socket d) Proxy Server

a

Which of these method of Thread class is used to Suspend a thread for a period of time? a) sleep() b) terminate() c) suspend() d) stop()

a

Which of these package is used for all the text related modifications? a) java.text b) java.awt c) java.lang.text d) java.text.mofify

a

Fill in the blanks so that this program displays a JFrame:> import java.awt.*; import javax.swint.*; public class microGUI { public static void main ( String[] args ) { JFrame frm = new ___________(); frm.___________( 150, 100 ); frm.___________( true ); } } A. Form, setVisible, setOn B. JFrame, setSize, setVisible C. Frame, setVisible, setSize D. Window, setSize, paint

b

How many ports of TCP/IP are reserved for specific protocols? a) 10 b) 1024 c) 2048 d) 512

b

Usually GUI programs are written by using existing software components provided in a toolkit. The Java toolkit used in this chapter is the: a. GUI toolkit b. Abstract Windowing Toolkit c. Graphics Event Toolkit d. Java Enhancement Toolkit

b

What is the output of this program? class newthread implements Runnable { Thread t; newthread() { t = new Thread(this,"My Thread"); t.start(); } public void run() { System.out.println(t); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } } a) My Thread b) Thread[My Thread,5,main] c) Compilation Error d) Runtime Error

b

What is the output of this program? import java.net.*; class networking { public static void main(String[] args) throws UnknownHostException { InetAddress obj1 = InetAddress.getByName("cisco.com"); System.out.print(obj1.getHostName()); } } a) cisco b) cisco.com c) www.cisco.com d) None of the mentioned

b

Which of these method is used to begin the execution of a thread? a) run() b) start() c) runThread() d) startThread()

b

Which of these method is used to implement Runnable interface? a) stop() b) run() c) runThread() d) stopThread()

b

Which of these methods is used to know host of an URL? a) host() b) getHost() c) GetHost() d) gethost()

b

Which of these package is used for remote method invocation? a) java.applet b) java.rmi c) java.lang.rmi d) java.lang.reflect

b

How many bits are in a single IP address? a) 8 b) 16 c) 32 d) 64

c

The three software parts of a GUI program are: a. Windows, Buttons, Mice b. GUI Components, Graphics, Code c. GUI Components, Event Listeners, Application Code d. Frames, Code, Events

c

What is the length of the application box made by this program? import java.awt.*; import java.applet.*; public class myapplet extends Applet { Graphic g; g.drawString("A Simple Applet",20,20); } a) 20 b) Default value c) Compilation Error d) Runtime Error

c

What is the name of the Swing class that is used for frames? A. Window B. Frame C. JFrame D. SwingFrame

c

What is the name of the thread in output of this program? class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); System.out.println(t.isAlive()); } } a) 0 b) 1 c) true d) false

c

What is the output of this program? import java.lang.reflect.*; class Additional_packages { public static void main(String args[]) { try { Class c = Class.forName("java.awt.Dimension"); Field fields[] = c.getFields(); for (int i = 0; i < fields.length; i++) System.out.println(fields[i]); } catch (Exception e){ System.out.print("Exception"); } } } a) Program prints all the constructors of 'java.awt.Dimension' package. b) Program prints all the methods of 'java.awt.Dimension' package. c) Program prints all the data members of 'java.awt.Dimension' package. d) program prints all the methods and data member of 'java.awt.Dimension' package.

c

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.getHost()); } } a) sanfoundry b) sanfoundry.com c) www.sanfoundry.com d) http://www.sanfoundry.com/javamcq

c

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

c

Which of these exception is thrown by URL class's constructors? a) URLNotFound b) URLSourceNotFound c) MalformedURLException d) URLNotFoundException

c

Which of these method of Thread class is used to find out the priority given to a thread? a) get() b) ThreadPriority() c) getPriority() d) getThreadPriority()

c

Which of these method waits for the thread to treminate? a) sleep() b) isAlive() c) join() d) stop()

c

Which of these package contains classes and interfaces for networking? a) java.io b) java.util c) java.net d) java.network

c

What is a container object in GUI programming? a. A container is another name for an array or vector. b. A container is any class that is made up of other classes. c. A container is a primitive variable that contains the actual data. d. A container is an object like a Frame that has other GUI components placed inside of it.

d

What is the output of this program? import java.io.*; import java.net.*; public class URLDemo { public static void main(String[] args) { try { URL url=new URL("http://www.sanfoundry.com/java-mcq"); System.out.println("Protocol: "+url.getProtocol()); System.out.println("Host Name: "+url.getHost()); System.out.println("Port Number: "+url.getPort()); } catch(Exception e){System.out.println(e);} } } a) Protocol: http b) Host Name: www.sanfoundry.com c) Port Number: -1 d) all above mentioned

d

Which of these class is used to access actual bits or content information of a URL? a) URL b) URLDecoder c) URLConnection d) All of the mentioned

d

Which of these is a full form of DNS? a) Data Network Service b) Data Name Service c) Domain Network Service d) Domain Name Service

d

Which of these methods are member of Remote class? a) checkIP() b) addLocation() c) AddServer() d) None of the mentioned

d

What is Remote method invocation (RMI)? a) RMI allows us to invoke a method of java object that executes on another machine. b) RMI allows us to invoke a method of java object that executes on another Thread in multithreaded programming. c) RMI allows us to invoke a method of java object that executes parallely in same machine. d) None of the mentioned

a

What is the output of this program? import java.lang.reflect.*; class Additional_packages { public static void main(String args[]) { try { Class c = Class.forName("java.awt.Dimension"); Constructor constructors[] = c.getConstructors(); for (int i = 0; i < constructors.length; i++) System.out.println(constructors[i]); } catch (Exception e){ System.out.print("Exception"); } } } a) Program prints all the constructors of 'java.awt.Dimension' package. b) Program prints all the possible constructors of class 'Class'. c) Program prints "Exception" d) Runtime Error

a

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

a

Which of the following sets the frame to 300 pixels wide by 200 high? A. frm.setSize( 300, 200 ); B. frm.setSize( 200, 300 ); C. frm.paint( 300, 200 ); D. frm.setVisible( 300, 200 );

a

What method sets the size of the displayed JFrame? A. setSize( int width, int height) B. setSize( int height, int width) C. setVisible( int width, int height) D. setVisible( int height, int width)

a

Which of the following sets the frame to 300 pixels wide by 200 high? a. frm.setSize( 300, 200 ); b. frm.setSize( 200, 300 ); c. frm.paint( 300, 200 ); d. frm.setVisible( 300, 200 );

a

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

c

When is the paint() method of a frame object called? a. The user calls it to display the frame. b. The main() method calls it once when the program starts. c. The Java system calls it every time it decides to display the frame. d. The Java system calls it once when the program starts.

c

Which of these class is used for creating a client for a server-client operations? a) serverClientjava b) Client.java c) AddClient.java d) ServerClient.java

c

Which of these class is used to encapsulate IP address and DNS? a) DatagramPacket b) URL c) InetAddress d) ContentHandler

c

Which of these class is used to make a thread? a) String b) System c) Thread d) Runnable

c

What is the output of this program? class newthread implements Runnable { Thread t; newthread() { t = new Thread(this,"My Thread"); t.start(); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } } My Thread b) Thread[My Thread,5,main] c) Compilation Error d) Runtime Error

c

What is the priority of the thread in output of this program? class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); t.setName("New Thread"); System.out.println(t.getName()); } } a) main b) Thread c) New Thread d) Thread[New Thread,5,main]

c

. What is the output of this program? class newthread implements Runnable { Thread t; newthread() { t1 = new Thread(this,"Thread_1"); t2 = new Thread(this,"Thread_2"); t1.start(); t2.start(); } public void run() { t2.setPriority(Thread.MAX_PRIORITY); System.out.print(t1.equals(t2)); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } } a) true b) false c) truetrue d) falsefalse

d

In Java, what do you call an area on the screen that has nice borders and various buttons along the top border? A. A window. B. A screen. C. A box. D. A frame.

d

The size of a frame on the screen is measured in: A. inches B. nits C. dots D. pixels

d

What is a container object in GUI programming? A. A container is another name for an array or vector. B. A container is any class that is made up of other classes. C. A container is a primitive variable that contains the actual data. D. A container is an object like a frame that has other GUI components placed inside of it.

d

What is the name of the thread in output of this program? class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); System.out.println(t.getPriority()); } } a) 0 b) 1 c) 4 d) 5

d

What is the output of this program? class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); t.setName("New Thread"); System.out.println(t); } } a) Thread[5,main] b) Thread[New Thread,5] c) Thread[main,5,main] d) Thread[New Thread,5,main]

d

What is the output of this program? class newthread implements Runnable { Thread t; newthread() { t = new Thread(this,"New Thread"); t.start(); } public void run() { t.setPriority(Thread.MAX_PRIORITY); System.out.println(t); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } } a) Thread[New Thread,0,main] b) Thread[New Thread,1,main] c) Thread[New Thread,5,main] d) Thread[New Thread,10,main]

d

What is the output of this program? import java.net.*; class networking { public static void main(String[] args) throws UnknownHostException { InetAddress obj1 = InetAddress.getByName("cisco.com"); InetAddress obj2 = InetAddress.getByName("sanfoundary.com"); boolean x = obj1.equals(obj2); System.out.print(x); } } a) 0 b) 1 c) true d) false

d

Fill in the blanks so that the following draws a Frame containing "Hello". import java.awt.*; class helloFrame ___________ Frame { public void ___________( Graphics g ) { g.___________("Hello", 10, 50 ); } } public class Tester { public static void main ( String[] args ) { helloFrame frm = new helloFrame(); frm.setSize( 150, 100 ); frm.setVisible( true ); } } a. import, drawString, paint b. extends, paint, drawString c. extends, draw, paint d. include, drawString, paint

b

Fill in the blanks so that this program displays a Frame: import java.awt.*; public class microGUI { public static void main ( String[] args ) { Frame frm = new ___________(); frm.___________( 150, 100 ); frm.___________( true ); } } a. Form, setVisible, setOn b. Frame, setSize, setVisible c. Frame, setVisible, setSize d. Window, setSize, paint

b

What is the output of this program? import java.lang.reflect.*; class Additional_packages { public static void main(String args[]) { try { Class c = Class.forName("java.awt.Dimension"); Method methods[] = c.getMethods(); for (int i = 0; i < methods.length; i++) System.out.println(methods[i]); } catch (Exception e){ System.out.print("Exception"); } } } a) Program prints all the constructors of 'java.awt.Dimension' package. b) Program prints all the methods of 'java.awt.Dimension' package. c) Program prints all the data members of 'java.awt.Dimension' package. d) program prints all the methods and data member of 'java.awt.Dimension' package.

b

Which function of pre defined class Thread is used to check weather current thread being checked is still running? a) isAlive() b) Join() c) isRunning() d) Alive()

d

Which of these methods is used to know the full URL of an URL object? a) fullHost() b) getHost() c) ExternalForm() d) toExternalForm()

d

Which of these statement is incorrect? a) A thread can be formed by implementing Runnable interface only. b) A thread can be formed by a class that extends Thread class. c) start() method is used to begin execution of the thread. d) run() method is used to begin execution of a thread before start() method in special cases.

d


Related study sets

Med Surg Exam 3 Practice Questions Part 4

View Set

Practice assessment blood and fluid disorders test ATI

View Set

NCLEX Prep II Renal and Urinary Medications Chapter 59

View Set

Unit 11 SIE Economic Indications

View Set

Brain Drain: Structure of Matter part 2

View Set

One Word Answer Quiz Julius Caesar

View Set

Google AI Shopping Ads Assessment

View Set