--------------------------------------------------------------------------------------------------------------------------
Prepared By : Uday Shah (HOD - IT)
Contact No : 7600044051
E-Mail : rupareleducation@gmail.com
Core Java and Advance Java One Mark Question
1. java programs
are
Ans: Platform independent
2. Java has its
origin in
Ans: Oak
programming language
3. Which one of
the following is true for Java
Ans: Java is
object oriented and interpreted
4. The command
javac is used to
Ans: compile a
java program
5. Java servlets
are an efficient and powerful solution for creating ………….. for the web.
Ans: Dynamic
content
6. Filters were
officially introduced in the Servlet …………specification.
Ans: 2.1
7. Which is the
root class of all AWT events
Ans:
java.awt.AWTEvent
8. OOP features
are
i) Increasing
productivity ii)
Reusability
iii) Decreasing
maintenance cost iv) High
vulnerability
Ans: 1,2
& 3
9. break statement
is used to
i) get out of
method ii) end aprogram
iii) get out of a
loop iv) get out of the system
Ans: 3
10. Native –
protocol pure Java converts ……….. into the ………… used by DBMSs directly.
Ans: JDBC
calls, network protocol
11. The JDBC-ODBC
bridge allows ……….. to be used as ………..
Ans: ODBC
drivers, JDBC drivers
12. Which of the
following is true about Java.
Ans: Java does not support overloading.
Java has replaced the destructor function of C++
There are no header files in Java.
13. ……………. are not
machine instructions and therefore, Java interpreter generates machine code
that can be directly executed by the machine that is running the Java program.
Ans: byte code
14. The command
javac
Ans: Converts a
java program into bytecode
15. Which of the
following is not the java primitive type
Ans: Long
double
16. Command to
execute compiled java program is
A) java
17. Java Servlet
Ans: is key component of server side java
development
18. Inner classes
are
Ans: nested
classes
19. How many times
does the following code segment execute
int x=1, y=10,
z=1;
do{y–;
x++; y-=2; y=z; z++} while (y>1 && z<10);
Ans: 1
20. State weather
the following statement is true or false for EJB.
1. EJB exists in
the middle-tier
2. EJB specifies
an execution environment
3. EJB supports
transaction processing
A) 1-true, 2.
true, 3. true
B) 1- true, 2.
false, 3. true
C) 1- false, 2-
false, 3- false
D) 1-true, 2-true,
3-false
21. All java
classes are derived from
Ans:
java.lang.Object
22. The jdb is
used to
Ans: Debug a
java program
23. Which method
will a web browser call on a new applet?
Ans: init
method
24. Which of the
following is not mandatory in variable declaration?
C) an
assignment
25. When a program
class implements an interface, it must provide behavior for
Ans: all
methods defined in that interface
26. In order to
run JSP is required.
Ans: Java Web
Server
27. Prepared
Statement object in JDBC used to execute queries.
Ans:
Parameterized
28. In Java
variables, if first increment of the variable takes place and then the
assignment occurs. This operation is also called
Ans: pre
increment
29. When the
operators are having the same priority, they are evaluated from in the order
they appear in the expression.
B) left to
right
30. In java, can
only test for equality, where as can evaluate any type of the Boolean
expression.
Ans: switch, if
31. The looks only for a match between the value of
the expression and one of its case constants.
Ans: switch
32.
System.in.read() is being used, the program must specify the clause.
Ans:
throws.java.io.IOException
33. By using you can force immediate termination of a
loop, by passing the conditional expression and any remaining code in the body
of the loop.
Ans:Break
34. The out object
is an object encapsulated inside the
class, and represents the standard output device.
Ans: system
35. The third type
of comment is used by a tool called for automatic generation of documentation.
Ans: Java doc
36. The compiled
java program can run on any plateform having Java Virtual Machine (JVM)
installed on it.
C) hardware
37.
Preparedstatement Object in JDBC is used to execute queries.
Ans:
parameterized
38. In JDBC
imports all Java classes concerned with database connectivity.
Ans: java.sql.*
39. MS-SQL stores
data in a file format.
Ans: .DAT
40. Ingres is a
Ans: Database
50. In Java
servlet method init( ) is called times.
Ans: 1
51. A method name
myMethod( ) that needs two integer arguments is declared as
Ans: public
void myMethod(int a, int b);
52. JSP embeds
in in
Ans: Java, HTML
53. The class at
the top of exception class hierarchy is
Ans: Throwable
54. In a java
program, package declaration import
statements.
Ans: must
precede
55. The class string
belongs to package.
Ans: java.lang
56. package is
used by compiler itself. So it does not need to be imported for use.
Ans: java.lang
57. The and
classes are abstract classes that support reading and writing of byte streams.
Ans: inputstream,
outputstream
58. What is the
error in the following code?
class Test
{
abstract void
display( );
}
Ans: Test class
should be declared as abstract
59. A package is a
collection of
Ans: classes
and interfaces
60. Which of the
following methods belong to the string class?
A) length( )
B) compare To ( )
C) equals ( )
D) All of them
61. Which of the
following control expressions are valid for an if statement?
Ans: A Boolean
expression
62. The concept of
multiple inheritance is implemented in Java by
Ans: extending one class and implementing one
or more interfaces
implementing two or more interfaces
63. Which of the
following do not represent legal flow control statements?
Ans: exit();
64. Data input is
Ans: an
interface that defines methods to read primitive data types.
65. Using which keyword we can access value of the
instance variables and class variables of that class inside the method of that
class itself.
Ans: this
66. If a variable
is declared final, it must include value.
Ans: initial
67. In java,
string is a
Ans: abstract
data type
68. Each method in
a java class must have a unique name .
Ans: Not necessary
69. It is
important feature of java that it always provides a default constructor to a class.
Ans: True
70.
.................. is the key to ………………….
Ans:Serialization,
persistence
71. Java programs
perform I/O through
Ans: I/O
package
72. What is byte
code in the context of Java?
Ans: The type
of code generated by a Java compiler
73. The new
operator dynamically allocates for an object and returns a reference to it.
Ans: memory
74. What is the
priority of the Garbage collector thread of jdk?
Ans: Low
Priority
75. is a feature
that allows one interface to be used for a general class of actions.
Ans: Polymorphism
76. The default
package that is implicitly called in a java program is
A) java.Lang
77. What is the
file extension of compiled java program?
Ans: .class
78. keyword is
used to invoke the current object.
Ans: This
79. Which of the
function is used to convert string to Number in java program?
Ans: valueOf()
80. What are the
part in executing a Java program and their purposes?
Ans: Java
Compiler
81. Method
overloading is one of the way that Java supports
D) polymorphism
82. Java support
RMI. What does this RMI stands for?
Ans: Remote
Method Invocation
83. Which of the
following represent legal flow control statements?
Ans: break;
84. The keywords
reserved but used in the initial version of Java are
Ans: union
85. What is the
default return type of main() ..
Ans: int
86. A java program
is first ……………… and ……………………
Ans: compiled, run
87. Byte code is
also a ………
Ans: machine code
88. A private
class is accessible from inside a
Ans:
package
86. Adapter
classes are used for ……….
Ans: code redundancy
87. …………….. is
generated if a button is clicked in AWT.
Ans: ActionEvent
88. Using which
keyword we can access value of the instance and class variables of that class
inside the method of that class itself.
Ans: super or this
89. If a variable
is declared FINAL, it must include
value.
Ans:
integer
90. In java,
string is a
Ans:
primitive data type
91. Methods can be
overloaded with a difference only in the type of the return value
Ans: False
92. Each method in
a java class must have a unique name
Ans: Not necessarily
93. Life cycle of
an applet is described by methods.
Ans: five
94. In java RMI,
stub is located in
Ans: client machine
95. ODBC stands
for
Ans: Open Database Connectivity
96 …………is passed
to a method by use of call by reference.
Ans:
Objects
97. Using the
keyboard interface you can fully abstract a ……..
Ans:
Class
98. Java is
designed for environment of the
Internet.
Ans:
Distributed
99. Variable
declared as do not occupy on a per instance basis.
Ans:
Final
100. The statement
is used to terminate a statement sequence.
A.
Break
101.
Multidimensional arrays are actually
Ans:
Arrays of arrays
102. ………… is used
for initialize the value to the string object.
Ans:
String literals
103. Object is
an of class.
Ans:
instance
104. One interface
can inherit another by use of the keyword
Ans:
extends
105. must be the first non comment statement in
the file
Ans: package
106. The string is
defined in name space.
Ans: java.Lang
107. A object cannot be modified after it is
created.
Ans:
string
108 …………. is a
special member function.
Ans:
constructor
109. A class may not have any abstract method.
Ans:
final
110. ………. is a small unit of process.
Ans:
thread
111. ………… is valid for if statement?
Ans:
A Boolean expression
112 ……………… operators which concatenates two
strings.
Ans:
+
113. ____ are instructions that are not for any
specific cpu. instead they are designed to be interpreted by a JVM.
Ans: Byte Codes
114. The
advantage of such a design is that the ____ class specifies what functionality
is provided but not how that functionality is provided.
Ans: Final
115. To create an array of 7 integers which
statement to write?
Ans: int a[]=new int [7];
116. When an object is no longer referenced by any
variable, it then becomes eligible for ________.
Ans: Garbage collection.
117. What is the
output of this program?
Ans: Compile time error.
118. ____ is shared by all objects of its class
and thus relates to the class itself.
Ans: Global variable.
119. Which
method is used to perform some actions when the object is to be destroyed?
Ans: Finalize()
120. When an
array element is accessed beyond the array size,___ exception is thrown.
Ans: ArrayIntexOutOfBoundsException
121. A method implementation of an interface must
be declared as _____.
Ans: public
122. A class
can extend ____ class and can implement _____ interface.
Ans: One
class and more one than interface.
123. When
a method can throw an Exception then it is specified by ____
keyword.
Ans: throws
124. To
create our own Exception class, we have to write ____.
Ans: Create
our own try and catch block.
125. From the
following methods which method cannot cause a thread to go into a blocked
state?
Ans: Sleep()
126. When
a method is used by two threads,then is should be declared by
____ keyword.
Ans: synchronize
127. When a
method has same name and same type signature as a method in super class, then
this method is said to be _____.
Ans: Overridden
128. Which
method wake up the first thread that called wait() on same object?
Ans: Notify()
129. What
is vector class?
Ans: Is
collection on different data types same
object.
130. Which
interface must be implementing when using scrollbar in
Applet?
Ans: AdjustmentListener
131. Sometimes we want to
pass information into a program when we run it, which is done by passing ___ to
main().
Ans: Command
line argument.
132. ____
is used to indicate that no further alterations can be made.
Ans: final
133. When a member is
declared as a, ___ is cab be accessed before any object of its class are
created, and without reference to any object.
Ans: static
134. which method will
cause a JFrame to display?
Ans: setVisible()
135. How
do you change the current layout manager for a container which
method is used?
Ans: setLayout
method.
136. The
(0,0) co-ordinates of Applet window is located at____
Ans: At
the upper-left corner of the applet,
137. Syntax of replace()
of string class is ___
Ans: Str.replace(str1,str2)
138. Which
methods is used to delete more then one character from string?
Ans: deleteCharAt()
139. The ____ contains all
the graphics methods, all then windowing methods, and the components needed to
create user interfaces.
Ans: Java.awt
package
140. Syntax of drawstring in Applet.
Ans: g.drawString(int
x,int y,String)
141. ____
occurs when a class declares a method that has the same type signature as a
method declared by one of its super classes.
Ans: Method Overriding.
142. What is class?
Ans:
Class
is a collection of different method and variable.
143. Syntax of delete() method is StringBuffer
class.
Ans: Delete(char ch)
144.
What is the output of this program?
Ans:
Compile
time error.
145. To find
the value associated with the specified key ___ method is used.
Ans: getValue(object key)
146.
If another thread attempts to execute a ____ static
method for that same class,the JVM automatically causes that thread to wait
until the first thread relinquishes the lock.
Ans: Synchronized
147. AdjestmentListener
interface defines the ___ method that is invoked when an adjustment event
occurs.
Ans: adjustmentValueChanged(AdjustmentEvent
e)
148. Write constructor for JFrame.
Ans: JFrame(String title)
149. The ___
class allows you to write programs that can seek to any location in a file read
or write data at that point.
Ans: Random access file.
150. Which
layout manager allows placing components one after another as well one on top
of another?
Ans: Card Layout
151. In event
handling, sometimes we need only one or some methods of the interface in that
case ___ are the best solution.
Ans: Adapter class
152 The ____
method is called when your applet is to be terminated and needs to be removed
from the memory.
Ans: Destroy()
153. Java is an
______ language.
Ans: Object oriented, multi thread programming
154. Java was
developed by.
Ans: Sun Microsystems
155. Java is designed
to the basis of _______ keys.
Ans: powerful programming language
156. Java
development environment there are ______ parts.
Ans: Java Interpreter
157. The
Compiler _________.
Ans: Execute java program
158. The
Interpreter ________.
Ans: Generates Byte Code
159. Java enables
the creations of ______ programs.
Ans: cross-platform, right-platform
160. RMI Stand
for ____________.
Ans: Remote Method Invocation
161. In java de-allocations
happens_____.
Ans: Automatically
162. Class inherits
from the ______.
Ans: Object
163. Object
class is the ________ of all the class in the java class hierarchy.
Ans: Subclass
164. How many
types of method declare in java?
Ans: 3
165. Overloading
Method demonstrate the concept of ________
Ans: Polymorphism
166. What is
the argument type of Program's main() method
Ans: String Array
167. What is
the primitive data type.
Ans: Byte,Short
168. Which cast
must be used to convert a large value into smaller one.
Ans: Explicit
169. You would
use the ______ operator to create a single in stance of a named class.
Ans: new
170. Which of
the following classes is used to perform
basis consol I/O.
Ans: System
171. ____ is
the processing of calling the f unction from the function itself.
Ans: Recursion
172. ______
applies only when inheritance is involved.
Ans: Protected
Best Of Luck
Please Share and Comment it... Thank You