Java Interview Questions - 5

 

Java Interview Questions

In our past post we have seen lot of Java interview question like programming. In this post lets see few multiple choice questions in Java. Lets get some basic knowledge on various topics in Java 


1. Enumeration doesn't have which of the following method?

a) Hasnext()
b) Next()
c) Both a & b
d) Remove()


2. The servlet handles zero or more client’s requests through which method?

a) Init()
b) Destroy()
c) Paint()
d) Service()


3. Which is an Interface that extends Serializable Interface?
 
a) Package
b) Classes
c) Externalizable
d) Abstract

  
4. Which of the following is a software component that has been designed to be reusable in a variety of different environments?
 
a) Jar file
b) Java bean
c) JVM
d) JDK


5. Which of the following is the software component that enables java application to interact with the database?
 
a) ODBC
b) API
c) JDK
d) JDBC


6. Who control the java collector?
 
a) Class
b) Java interface
c) Applets
d) JVM


7. Which allows null key and values?
 
a) Hashtables
b) Hashkeys
c) Hash set
d) Hash map

 
8. Which of the following is the JDBC driver?
 
a) AWT driver
b) Network protocol driver
c) JVM driver
d) JAR driver


9. Which method returns -1 when it has reached the end of a file?
 
a) Write()
b) Read()
c) Lock()
d) All the above


10. Which class of interface is used, where there is a collection with no duplicates and you don’t care about order when you iterate through it?
 
a) Tree set
b) Enum set
c) Hashset
d) Linked hashset


11. Which concept of object oriented programming helps you group features of an object?
 
a) Packages
b) Inheritance
c) Data abstraction
d) Expert system


12. Write down the syntax to set null layout?

a) SetLayout(null)
b) Layout(null)
c) Layout(set null)
d) Null layout


13. What is the base class of all the classes?
 
a) Java.lang
b) Java.object
c) Java.lang.object
d) Java.lang.class



Public class test {
static class innerclass { 
Public static void innermethod() {
System.out.ptintln("static inner class!";


Public static void main(string args[]) { 
Test.innerclass.innermethod(); 


14. What will be the output of the above program?
 
a) Static inner class
b) 16
c) 14
d) None of the above


15. The <an applet> tag enables to pass an applet parameter in an applet using which of the following tag?
 
a) Alt
b) Code
c) Align
d) Param

 
16. Which frees the memory occupies by the unreachable objects during the java program by deleting these unreachable objects?
 
a) Interface
b) JVM
c) Source code
d) Garbage collector


17. Which of the following modifier makes that the programmer cannot change the value anymore?
 
a) Protected
b) Private
c) Public
d) Final

 
18. Which of the following is the correct syntax to create static variable?
 
a) Type static <var>
b) Static <identifier> type
c) Static[] type <identifier>
d) Static type <identifier>

  
19. Which is a method of Object class which will be executed by the JVM just before garbage collecting object to give a final chance for resource?
 
a) String ()
b) Finalize()
c) Math()
d) Final()


20. Which of the following code shows how to call the garbage collector?
 
a) Get.gc()
b) Garbage collector()
c) Runtime.gc()
d) System.gc()


21. Which encapsulates the state changes in the event source?
 
a) Event source
b) Event object
c) Event listener
d) Event management


22. Which is the default layout of jpanel?
 
a) Text layout
b) Label layout
c) Frame layout
d) Flow layout


23. Which is the relationship between the two classes?
 
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Association


24. Which is Set implementation to use with enum types?
 
a) Util.java.enum
b) Java.util.enumset
c) Enumset.util
d) Java.enum


25. Which method can be accessed by the classes within the same package or by the sub-classes of the class in any package?
 
a) Public
b) Protected
c) Private
d) Void


26. Which of the following view lets you navigate through the various files that make up an Eclipse project?
 
a) Problem view
b) Explorer view
c) Debug view
d) Java view


27. Which of the following is the king of bugs of java program?
 
a) Incorrect result
b) Program crashes
c) Both a & b
d) None of the above


28. Which of the following option Skips the highlighted statement and executes the next statement, and then suspends the thread?
 
a) Run to return
b) Step into
c) Step over
d) Resume

 
29. Which of the following element specified the element that can occur 1 or more times?
 
a) Element *
b) Element -
c) Element +
d) Element ?


30. Which is a control that the user can click to either check or uncheck?
 
a) Radio button
b) Check box
c) Drop down List
d) All the above



31. After you compile a Java program with no errors, you can run it by choosing which key combination?
 
a) Ctrl+f2
b) Ctrl+8
c) Ctrl+4
d) Ctrl+2


32. In Java, a _______ is a unit of code that can calculate and return a value?
 
a) Identifier
b) Method
c) Variable
d) Data



33. Which of the java compiler option specifies where to find input source files?
 
a) -d <directory>
b) -extdirs <dirs>
c) -classpath <path>
d) -sourcepath <path>

  
34. Which command is called the Java dis-assembler because it takes apart class files and tells you what’s inside them?
 
a) Javac
b) Java
c) Javap
d) Javah

  
35. Which is a name and value pair that’s written inside of the start tag for an element?
 
a) DTD
b) Script
c) Code
d) Attribute


36. Which is a read-only technique for processing XML that lets you read the elements of an XML document from a file and react to them as they come?
 
a) SAX
b) DOM
c) XML
d) HTML


37. _______spells out exactly what elements can appear in an XML document and in what order the elements can appear?
 
a) DOM
b) SAX
c) Validate form
d) DTD

  
38. Which of the following java command option displays the JRE version number, then stops?
 
a) -version
b) –verbose
c) –showversion
d) –server

 
39. Which of the following operator is used to compile all the files in a folder of java programs?
 
a) $
b) *
c) @
d) &


40. Which of the following performs calculations?
 
a) Expression statement
b) Variables
c) Keywords
d) Declaration statement



41. Which is a line in your program where you want the program to be suspended?
 
a) Breakpoint
b) Trace
c) Stepping
d) Debug



42. Which of the following is based on interfaces rather than classes?
 
a) XML
b) Javascript
c) ASP
d) DOM API


43. Which is the basic Eclipse desktop environment?
 
a) editor
b) workbench
c) applets
d) javadoc



44. The text editor you wish to create the text files that contain your Java programs is called ______?
 
a) Source file
b) Destination file
c) Application file
d) System file


45. What is the size of offline version of java?
 
a) 100 gb
b) 45 mb
c) 90 mb
d) 150 mb

 
46. In text pad which is a collection of files that you work on together?
 
a) Preference
b) Javadoc
c) Applets
d) Workspace


47. Which method of the slider control sets the tool-tip text that’s displayed if the user rests the mouse over the slider for a few moments?
 
a) void setPaintLabels
b) void setToolTipText
c) setOrientation
d) void setMinimum()


48. Which document format that can be understood by most word processing programs?
 
a) JRE
b) RTF
c) Bin
d) Demo

  
49. Which is a group of one or more statements that’s enclosed in braces?
 
a) White space
b) Variable
c) Keyword
d) Blocks


50. When debugging is executing program statements one at a time is called _____?
 
a) Threads
b) Program crashes
c) Bugs
d) Stepping


No comments:
Write comments