You are on page 1of 33

SHORT QUESTIONS

General Questions:

1. Platform independence.

2. What do you meant by platform?

3. Byte codes

4. When byte codes are generated in java?

5. What is JVM?

6. What is the software used to develop the java applications and state

the current version.

7. Define architecture neutral.

8. “JVM is the same for all the platforms”. Justify it.

9. By default which package is imported by the java compiler?

10. Give the commands for compiling and running a java program

manually.

11.General form of a java class.

Method Overloading and Overriding:

1. Differentiate between method overloading and overriding

2. Type casting
3. Automatic conversion

4. Type promotion rules

5. Define inheritance.

6. Define multilevel inheritance.

7. How inheritance is identified in java?

8. What is dynamic method dispatch?

9. Explain dynamic method dispatch with related to method

overloading?

10.Explain dynamic method dispatch with related to method overriding?

11.Discuss about the three ways in which super can be used.

12.Why multilevel inheritance is not supported in java?

Interfaces and Packages:

1. Define package.

2. How a sub package which is present in another package is imported

in java.

3. What are the access specifiers present in java? Discuss about their

visibility

4. Define interface.

5. Whether interface can be extended by another interface.


6. When an interface becomes an abstract class.

7. Whether object can be created for an interface? Justify

8. Whether a reference variable can be created for interface? Justify

Streams

1. Define stream.

2. What are the two types of streams present in java?

3. Which two streams act as abstract class for byte oriented streams?

4. Which two streams act as abstract class for character oriented

streams?

5. Mention the use of filter streams.

6. Mention some of filter streams.

7. What is the use of a file class?

8. What are the exceptions thrown by Output Stream and Input Stream

class?

9. What are the exceptions thrown by Reader and Writer class?

10.What are the exceptions thrown by filereader and filewriter classes?

11.Discuss the use of Sequence Input Stream

Threads

1. Define thread.
2. Differentiate between thread and process.

3. Differentiate between multithreading and multitasking.

4. Distinguish between single threaded model and multithreaded model.

5. What are the two ways in which thread can be created?

6. How the constructors differs for the creation of thread using two ways.

7. Discuss about the lifecycle of a thread.

8. Define synchronization.

9. What are the methods used in interthread communication. State the

use of it.

Exception

1. Define exception.

2. What are the two types of custom exceptions that can be created in

java?

3. Mention some examples for checked exceptions.

4. Mention some examples for unchecked exceptions.

5. Discuss about the usage of try/catch block.

6. Differentiate between throw and throws.

7. Use of finally statement.


MODEL Q&A

Choose the Correct Answers:

1. The slogan of java is

a. Run once, write everywhere b. Write once, run

everywhere

c. Compile once, write everywhere d. None of these

2. long i = 700.20;

int j = (int) i; This type of casting is called as

a.Implicit casting b. Explicit casting c. Downcasting d.

Upcasting

3. The software that can be portable across various platforms is

a. Java Virtual Machine b.java Interpreter c. Java Compiler

d. Java Development kit

4. _________ is a variable and does not belong to instance of class but

rather shared across all the instances

a. member variable b. Class variable c. Automatic variable d.

Local variable

5. 1. Abstract class can be instantiated. 2. Can create a reference

variable for a abstract class


3. Abstract class can be sub classed 4. Abstract class contains

concrete methods.

Of the above which are true related to characteristics of abstract

class

a. All the four b.1, 2& 3 c.2, 3&4. d.1,2& 4.

6. What is the ultimate ancestor of all java classes

a. Lang b. Object c. util d. io

7. System.out.println("Hi");;;

The output of the above statement when included in main function is

a. Compile error b. Hi c. No output, no compile time error d.

None of these

8. Which is the first statement to be allowed in a java file and which

among these is a required one for a java program to run

1. Import 2. Class declaration 3. Package 4. Classes private

to package

a. 3 and 1,2,3 b. 1 and 1,2,3 c. 3 and 2 d. 1 and 2

9. MIME stands for_________________

a. Multipurpose Internet Mail extension b. Multiple

Internet Mail Extension


c. Multipurpose Intranet Mail extension d. Multiple Intranet Mail

extension

10. Which method in forms is used to pass the information as a

QueryString

a. POST b. GET c. PUT d. HEAD

11. The default layout manager for applet is________________

a. Gridlayout b. CardLayout c. Borderlayout d.

FlowLayout

12. ___________ is a required attribute in html that gives the name of

the file containing the applets compiled class file

a. CODE b.NAME c. CLASS d. APPLET NAME

13. The controls (or) components used in applet are present in the

package

a.java.applet.* b.java.awt.* c.java.awt.event.* d.

java.util.*

14. By means of interface java supports______ inheritance and

interface can be _________ and _________

a. multiple and implemented, extended b. multilevel and

implemented, not extended


c. multiple and implemented, not extended d. multilevel and

implemented,imported

15. ________ is a stateless protocol

a.UDP b. Hyper Text Transfer Protocol c. Hypertext

Transmission Protocol d. SMTP

16. Which is an optional part for URL

a. Hostname b. Path c. Port number

d.Protocol

17. Among the following which method must be overridden for a

generic servlet?

1. service (HTTPServletRequest req , HTTPServletresponse res)

2. service(ServletRequest req, Servletresponse res)

3. doService((HTTPServletRequest req , HTTPServletresponse

res)

4. service (ServletRequest req ,Servletresponse res)

a. 1 b. 2 c. 3 d.4

18. Socket is a combination of ________ and __________

a. Ipaddress and Port number b. ipaddress and protocol

c. ipaddress and hostname d. ipaddress and path


19. Which is a connection oriented protocol?

a. UDP b.IP c.TCP d.HTTP

20. Which of the following in Collection framework that contains

duplicate elements?

a. List b. Set c. Map d. SortedSet

I Class Test
1. What is the correct HTML for making a hyperlink

a. <a url="http://www.yahoo.com">Yahoo</a>
b. <a name="http://www.Yahoo.com">Yahoo</a>
c. <a>http://www.yahoo.com.com
d. <a href="http://www.yahoo.com">Yahoo one</a>
2. Which of these tags are all <table> tags

a. <table><tr><tt>

b. <table><tr><td>

c. <table><head><tfoot>

d. <thead><body><tr>

3. If you want to have the browser open a new window for a link to an
outside page, which attribute would you use?

a. alt

b. target
c. src

d. start

4. If you want your ordered list to use capital letters and start with the letter
D, which attributes would you use

a. type="a" start="D"

b. type="A" start="D"

c. type="A" start="4

d. type="letter” start=”D”

5. The anchor tag links to:

a. specific places within a particular page

b. other pages within your website

c. pages anywhere on the Internet

d. All of these are correct

6. HTML tags use brackets to contain the information. What kind of notation
do Cascading Style Sheets use to contain information?

a. Brackets, just like HTML

b. Parentheses

c. Curly brackets

d. Forward slashes

7. The default port number by which HTTP communication takes place is-
_________

a. 80 b. 120 c.25 d.70


8. Intranet is a ____________________-

a. Network of networks

b. Collection of networks

c. Connecting a organization network to another network

d. All of the above

9. Which one of the following protocols is used to store messages in


mailserver?

a. SMTP b. HTTP c.FTP d.POP3

10.________________ is a company that rents space on their webservers.

a. Web Hosting service b. Internet service provider

c. both a and b d. None of the above

11. The protocol by which webserver and webclient communicate is

a.FTP b. HTTP c.TCP d. IP

12. The need of archie software in FTP is

a. To search for the contents of the given filename in the ftpserver

b. To display the contents of the given filename.

c. To establish the communication between FTP client and FTP server

d. Both a & b

13. ___________ is a internet based system of interlinked pages of


information.

a. WWW b.Internet c.Intranet d.W3C

14. Each computer and a network device that are connected to the internet
are called as_________ and _________ respectively.
a. Node and Host b. Host and Node c. Device and Host d.
Node and device

15. __________ is an input for a specific internet service

a. Protocol b. Port c.Domain name d.URL

16. a. Files can be downloaded only

b. Files can be transferred to clients only via FTPserver

c. Files can be both downloaded and uploaded.

d. Communication takes place via FTP

Of the above following which of these is a characteristics of FTP


communication

a. a b. Both and b c. b,c and d d. All of the above

17. A high-speed connection to the Internet over standard lines.

a.DSL b. Dial Up networking c. Leased lines d. Both a and c

18. Plug-in is a _________

a. protocol used on the Internet that sends packets of information

b. program that enhances a browser's capability.

c. communicating real time on the Internet

d. a perfomance matrix used for authentic assessment

19. What does HTML do?

a. It processes code to form a program

b. It interprets code and display it on screen

c. It contains instructions for the browser to work

d. It is the language used to create websites


20. a. HTML Tags are case sensitive

b. Tables can be nested (table inside of another table).

c. Tags are the HTML codes that control the appearance of the document

contents

d. Action attribute specifies where to send the form

Out of the above which is (or) are false with related to HTML

a. a and b b. c and d c. b only d. a only

1) Two parts of java development environment are java compiler and

java interpreter.

2) On compilation of java file class files are generated.

3) Java compiler generates byte code instructions instead of machine

code

4) Java initially named as OAK.

5) Byte codes are executed by JVM(Java Virtual Machine)

6) The interpreter in java is called as Java Virtual Machine.

7) Two paradigms that govern how a program is constructed are process

oriented model and object oriented model.

8) Encapsulation is the mechanism that binds together code and data it

manipulates and keeps both safe from outside interference and misuse.

9) Objects are referred as instance of class.


10) The code and data that physically constitute the class are called as

members of the class.

11) Data defined by the class are called as member variables.

12) Member variables are also called as instance variables.

13) Inheritance is the process by which one object acquires the properties

of another object.

14) javac command is used to compile the java file.

15) For running an ex1.java file the command is java ex1.

16) The size of the data type in java remains the same on any machine

architecture.

17) The size and range of byte is 8 bits and -128 to 127.

18) The size and range of int is 32 bits and -32768 to 32767

19) Java uses Unicode format to represent characters.

20) In java char is 16 bits.

21) When byte is converted into int, this type of conversion is known as

widening conversion.

22) When int is converted into byte, this type of conversion is known as

Narrowing conversion.

23) When a floating point value is assigned to an integer type it is called as

truncation.
24) ? Operator in java is called as ternary operator.

25)Break statement can be used to

a. Exit a loop

b. As a form of goto.

c. To continue.

d. As a form of jump.

26) Class is a template for an object.

27) General form of a class does not have main method.

28) A constructor defines when an object of its class is created.

29) This keyword inside any method refers to current object.

30) When a local variable has same name as an instance variable, local

variable hides the instance variable.

31) This can be used to prevent instance variable hiding.

32)Finalize () method contains some code to free the resources before the

objects are destroyed.

33) The technique of deallocating objects in java is called as garbage

collection.

34) Member access in a class is determined by Access specifiers.

35) Group of classes is called as package.


36) When a member of a class is modifies by the public specifier, that

member can be accessed by another code.

37) The default access specifier in java is friendly.

38) Static members can be accessed before any of its objects are created.

39) Without reference to objects static members can be accessed.

40)1. Can only call static methods

2. Can access only static data.

3. Can refer to this or super in any way.

4. Can access all the data.

Which of the above statements are characteristics of static member?

a. 1 and 2 b. 2 and 3 c. 3 and 4 d. 1 and 4.

41) Final variable is essentially a constant.

42) A inner class is a non static nested class

43) The character at a specified index within a String is obtained by

charAt() method.

44) Inheritance is identified by extends keyword.

45)1. A super class variable can reference a subclass object.

2. super () is the first statement executed inside a subclass constructor.

3. A subclass variable can reference a super class object.


Which of the above statements are true?

a. 1 and 2 b. 2 and 3 c. 1 and3 d. None of these

46)Consider three classes A, B, C and D. Where B is inherited from A and C

is inherited from B and D is inherited from C (i.e.) A->B->C->D. Then

the constructors are called in the order

a. A constructor, B Const, C const(order of derivation)

b. B Const, C Const, A const

c. C const, B const, A const

d. A const, C const, B const

47) When a method in subclass has the same name and type signature as a

method in super class, the method in subclass is said to override the

method in super class.

48) Dynamic method dispatch is the mechanism by which a call to an

overridden method is resolved at run time.

49) Overridden methods are one way that java supports one interface,

multiple methods aspects of polymorphism.

50) A class which does not have concrete methods is called as abstract

class.

51) A abstract class may have abstract methods and concrete methods

52) When a class is declared as final it cannot be inherited.


53) The first statement in java file is package statement.

54) The mechanism in java for partitioning the class name space into more

manageable chunks is called as package.

55) The package statement defines a name space in which classes are

stored.

56) The default package imported by java compiler is java.lang.

57) Interface specifies what a class must do, but not how it does it.

58) A class can extend only one package at a time and can implement

more than one interface.

59) Multiple inheritances are supported in java by means of Interafce.

60) An interface contains method signatures and variables.

61) All exception is subclasses of Exception.

62) Division by Zero is an example of RunTime Exception.

63) An exception is an abnormal condition that arises in a code sequence

at run time.

64) An exception is a runtime error.

65) When using multiple catch statements exception subclasses must

come before any of their super classes.

66)Try{
}

Catch(Exception e) {}

} catch(ArithmeticException e1){}

Is the above statement true or false

False

Since Arithmetic Exception is a subclass of Exception it should be

catched before Exception.

67) Throw statement is used to manually throw an exception.

68) Finally creates a block of code that will be executed after a try/catch

block has completed.

69) Two types of exception in java are Unchecked Exception and

Checked Exception

70) Unchecked Exceptions are derived from RuntimeException Class.

71) Checked Exceptions are derived from Exception class.

Questions:

 Characteristics of java

 Method overriding vs method overloading

 This operator

 Constructors vs methods
 Inheritance-super keyword, Dynamic method dispatch

 Pgm in Multilevel inheritance

 Multilevel inheritance vs multiple inheritance

 Use of keywords Implements and extends

 Finally,final,finalaize()

 Exception handling mechanism with simple examples


1. Necessary support for applets is provided by Applet class

2. Applet class is present in java .applet package

3. AWT stands for Abstract Window Toolkit.

4. Applets can be executed by appletviewer or Java Compatible

browser.

5. The attribute of applet tag which contains the name of the applets

class file is CODE

<APPLET CODE=”DEMO” HEIGHT=200 WIDTH=200>

</APPLET> WHERE DEMO IS THE NAMEOF THE COMPILED

APPLET FILE

6. Applet extends Panel class.(Applet is derived from Panel class)

7. Panel extends Container class.

8. Container extends Component class

9. drawString() method is used to display some text on the screen in

applets

10. drawString() method is present in Graphics Class.

11. showStatus method displays the message at the footer .


12. The type of event handling followed in java is delegation event

model.

13. Event is an object that describes state change in source.

14. Event source is an object that generates an event.

15. Event Listener object is notified when an event occurs.

16. Action event is generated when a button is generated, a list item is

double clicked and menu item is selected.

17. When a scroll bar is manipulated Adjustment event is generated.

18. When a component is added Container Event is generated.

19. When a checkbox or list item is clicked Item Event is generated.

20. The label of the button can be retrieved by getActionCommand()

method.

21. Action Listener Interface defines one method to receive action events.

22.Adapter classes are useful when only some of the methods in listener

interfaces are to be implemented.

23. All user interface elements that are displayed on the screen and that

interact with the user are subclass of Component.

24. All user interface elements that are displayed on the screen and that

interact with the user belong to the package java.awt.*


25. Panel is a window that does not contain a title bar, menu bar or

border.

26. Button generates ActionEvents

27. Checkbox generates ItemEvents.

28. List generates ItemEvent and ActionEvent.

29. The method present in Action Listener Interface is actionPerformed

which takes ActionEvent as an argument.

(actionPerformed(ActionEvent e))

30. The method present in ItemListenerInterafce is itemStateChanged

which takes itemevent as an argument.(ItemStateChanged

(itemEvent i))

31. MouseClicked() method is present in MouseListener Interface.

32. The only two methods present in MouseMotionListener Interface is

MouseDragged() and MouseMoved().

33. Frame can be shown by setVisible method which takes Boolean

value as an argument. (setVisible (Boolean b)).

34. Lines are drawn by means of drawLine method

35.The foreground color of an applet can be set by

a. setForeground(Color.blue) b. setForeground(blue)

c. setColor(Foreground.blue ) d. setForeground(Color)
36.The background color of an applet can be set by

a. setBackground(Color.blue) b. setBackground(blue)

c. setColor(Background.blue ) d. setBackground(Color)

37. Two types of color schemes followed in java are RGB (Red, blue, green)

and HSB (HUE, Saturation, Brightness).

38. Controls (checkbox, text field, button etc) are components that allow

a user to interact with components.

39. Controls in applets are present in package java.awt.*

40. Radio button in applets are created by checkBoxGroup class

41. Layout Manager automatically positions the components or controls

within a container

42. Which class allows selecting a single option? Choice

43. Which class in applets allows selecting a multiple option? List

44. The layout manager in applets is set by setLayout method.

45. Flow layout lays the components like a text editor.

46. The default layout manager in applets is FlowLayout

47.___________ is not a valid value for a flowLayout

a. Flowlayout. Center b. Flowlayout.East c. Flowlayout.Left

d. Flowlayout.Right
48. Border layout contains 4 fixed width components and one large area

in the center.

49. Applet is a small program that can be transported over network.

50. Applet is executed on the client side(by browser)

51. Applets are also known as client side applets.

52. Applets won’t have main method.

53. Current state of the checkbox can be retrieved by getState method.

54. Label of the checkbox can be retrieved by getLabel() method

Questions

1. Define applet.

2. Difference between applet and application

3. Difference between applet and servlets.

4. Life cycle of applet

5. Different Layouts

6. Program in Event handling

7. Event, Even source, Event Listeners roles


8. Sources of various events and description of various

events.

9. Adapter classes.

Java Servlets

1. In the earlier days communication between Web client and web server

takes place via between CGI(Common Gateway interface)

2. In servlets service method is called to process the requests

3. Java Server Development Kit (JSDK) contains the libraries to create

servlets.

4. All Servlets must implement the Servlet interface or it must extend

the class that implements the Servlet interface.

5. Generic Servlet class implements Servlet interface.

6. Servlets are executed at server side


7. javax.servlet package contains the classes and interfaces required to

build servlets.

8. Two types are servlets are GenericServlet and Http Servlet

9. HttpServlet is a ____________ type of servlet

a. Protocol Independent b. Protocol dependent c. independent d.

dependent

10. MIME stands for Multipurpose Internet Mail Extension.

11. setContentType() method in servlets is used to establish the MIME

type of Servlets response.

12.Which package is required to build a generic servlets?

a. javax.servlet.http.*; c. javax.servlet.*;

b. java.servlet.*; d. java.servlet.http.*;

13.Which packages are required to build a Http Servlets

1. javax.servlet.http.*; 2. javax.servlet.*;

3. java.servlet.*; 4.java.servlet.http.*;

a. 1 and 2 b. 2 and 3 c. 3 and 4 d. 1 and 4

14.Which method must be overridden for generic servlets?

a. service(ServletRequest req, ServletResponse res)

b. service(HttpServletRequest req, HttpServletResponse res)


c. doService (ServletRequest req, ServletResponse res)

d. doService (HttpServletRequest req, HttpServletResponse res)

15. GET method in form passes the data as queryString

(Entering ” yahoo” in google.co.in and pressing enter, automatically in

the address bar the information entered by the user will be appended

like…www.google.co.in?search=yahoo)

16. POST method in form passes the data confidentially

17. Lifecycle method of servlets is present in Servlet interface.

18.Which of the following constitute the lifecycle of servlets.

a. Init(),paint(),service(),destroy()

b. Init(),doget(),service(),destroy()

c. Init(),service(),destroy()

d. Init(),doPost(),destroy()

19. ServletConfig interface allows servlets to obtain information about

their environment.

20. Exceptions thrown by servlets are Servlet Exception and

UnavailableExeption.

21. The value entered by the user in form can be retrieved in servlets via

getParameter() method, which is present in ServletRequest

interface.
22. Cookie is stored on a client and contains state information.

23. Cookie can be written to a user machine by addCookie () method.

24._______ is not a part of cookie information

a. Data b. name c. value d. domain name e. expiration

date.

25. doGet must be overridden in HTTPServlet if the HTML form contains

GET method.

26. doPost must be overridden in HTTPServlet if the HTML form contains

POST method.

27. HTTP (HyperText Transfer Protocol) is a stateless protocol.

28. getCookie() method is used to read any cookie from a client request.

Networking:

29. Networking classes in java are defined in java.net package.

30. Socket is a combination of IPAddress and Port Number.

31. Networking applications in java communicate via sockets.

32. TCP(transmission Control Protocol) is a connection-oriented

and reliable protocol

33. UDP (User Datagram Protocol) is a connectionless and

unreliable protocol.
34. UDP provides faster data transfer than TCP.

35. The default port number for FTP is 23

36. The default port number for telnet is 25.

37. The default port number for HTTP is 80.

38. The default port number for email is 25.

39. IPv4 address is 32 bits.

40. The conversion of domain names into IPaddress and vice versa is done

by Domain Naming Service.

41. IPAddress class in java is used to encapsulate both the numerical

IPaddress and domain names.

42. Factory methods are convention whereby static methods in class

return the instance of the class.

43. getLocalHost() method simply returns the InetAddress object that

represents the local host.

44. getByName() method returns the InetAddress object for a host name

passed to it.

45. Two kinds of Sockets in java are TCP sockets and UDP sockets.

46. Two kind of TCP socket class in java are ServerSocket and Socket.

47. UDP Socket contains Datagram Packet and DatagramSocket class.


48. Datagram Packet class in UDP acts as a container

49. Send and receive methods in UDP are present in Datagram Socket

class.

50. Datagrams are bundles of information of information passed between

machines.

51. DatagramSocket is the mechanism used to send and receive

DatagramPackets

52. URL stands for Uniform Resource Locator.

53.The components of URL are in the correct order are

a. Protocol,domain name, path, portnumber.

b. Protocol,path,portnumber,domain name

c. Protocol, domainname, path, port number

54. Port number is the optional part of URL.

55. URLConnection is a general purpose class for accessing remote

resource.

56. RMI stands for Remote Method Invocation.

57. The mechanism which allows a java object that executes on one

machine to invoke a method of java object on another machine is RMI.

58. Remote interfaces in RMI must extend the Remote Interface which is

present in java.rmi.package.
59. Lookup() method is used in client side to check in the RMI registry..

60. Rebind() method is used in the server side to bind the component in

the RMI registry.

61. Stub is a java object that resides on client machine.

62. Skeleton is a java object that resides on server machine.

63. Stub and skeletons are generated by rmicompiler(rmic)

64. JDBC stands for Java Database Connectivity.

65. The mechanisms for accessing the various databases are present in

java.sql.*

66. JDBC is an API specification developed by Sun Microsystems that

defines a uniform interface for accessing various relational databases.

67. The JDBC driver manager ensures that the correct driver is used to

access each data source.

68.Four types of JDBC-ODC drivers are

Type 1 JDBC-ODBC Bridge, Type 2 Java to Native API, Type 3 Java

to Network Protocol, Type 4 Java to Database Protocol

Questions:

1.Servlets vs CGI.

2. Simple program in generic servlets and HTTP servlets(printing hello

world).
3. Life cycle of servlets.

4. HTML form processing(lab program).

5. Cookies(Writing cookie and reading a cookie)

6. SessionTracking.

7. JDBC drivers.

8 .Program in UDP nd TCP sockets.

9. Reading a contents from a website (Using URL connection).

10. RMI architecture with an example.

11.JDBC drivers.

12. Pgm in jdbc.

You might also like