List Of Best Java Multiple Choice Questions
and
Answers
1. Why Java and JavaScript have same name?
a)
JavaScript works as a version stripped-down of
the Java
b)
Both are originated in island of the Java
c)
Javacript’s syntax is based on the Java’s
Answer: c
2. If you will view the JavaScript page, which machine will
execute the socalled script?
a)
Machine running the online browser
b)
Central machine within the Netscapes corporate
offices
c)
Web server
Answer: a
3. ____JavaScript is referred as client-side.
a)
Livewire
b)
Native
c)
Microsoft
Answer: a
4. What variables are being used in the programs
for the JavaScript?
a)
Dates, stroning numbers and others
b)
Algebra flashbacks
c)
Varying randomly
Answer: a
5. ____ JavaScript statement embedded in the HTML page
responding to the user events?
a)
Server-side
b)
Native
c)
Client-side
Answer: c
6. In the end of the JavaScript, what will appear?
a)
The <script>
b)
The </script>
c)
End statement
Answer: b
7. What cannot be done in the client-side of the JavaScript?
a)
Storing forms contents to file database on
server
b)
Sending forms contents
c)
Validating form
Answer: a
8. Which are the capabilities functions in the
JavaScript?
a)
Accept parameters
b)
Return the value and accept parameters
c)
Return the value
Answer: a
9. Which is invalid variable name of JavaScript?
a)
First and last names
b)
First and last
c)
2names
Answer: c
10.____ tag is the extension to the HTML enclosing number of the
JavaScript statement.
a)
<SCRIPT>
b)
<TITLE>
c)
<HEAD>
Answer: a
11.How the JavaScript store dates in date object?
a)
The number of the milliseconds since 1st
January 1970
b)
The number of the days since 1st January1900
c)
No answer
Answer: a
12. Which attribute will able to hold JavaScript version?
a)
LANGUAGE
b)
VERSION
c)
SCRIPT
Answer: a
13.What JavaScript syntax is correct in writing the "Hello
World"?
a)
println ("Hello World")
b)
System.out.println("Hello World")
c)
document.write("Hello World")
Answer: c
14.Which way can be used in indicating LANGUAGE
attribute?
a)
<SCRIPT LANGUAGE="JavaScriptVersion"!> JavaScript statements…</SCRIPT>
b)
<SCRIPT
LANGUAGE="JavaScriptVersion">
c)
<SCRIPT
LANGUAGE="JavaScriptVersion">
JavaScript statements…</SCRIPT>
Answer: c
15.In what HTML element you put JavaScript?
a)
<js>
b)
<scripting>
c)
<script>
Answer: c
16.What correct syntax referring to the external script called
" abc.js"?
a)
<script href=" abc.js">
b)
script src=" abc.js">
c)
<script name=" abc.js”>
Answer: b
17.Which image maps types can be used with the JavaScript?
a)
Server-side image maps
b)
Server-side image maps and the Client-side
image maps
c)
Client-side image maps
Answer: c
18.Which navigator object properties is the same in both IE and
Netscape?
a)
navigator.appCodeName
b)
navigator.appVersion
c)
navigator.appName
Answer: a
19.Correct way in writing the JavaScript array?
a)
var txt = new
Array("tim","kim","jim")
b)
var txt = new
Array:1=("tim")2=("kim")3=("jim")
c)
var txt = new
Array="tim","kim","jim"
Answer: a
20.What does <noscript> tag do?
a)
Enclose text that to be displayed by the non-JavaScript
browsers
b)
Describes certain low-budget movies.
c)
Prevents scripts on page from executing.
Answer: a
21. If para1 is DOM object for a paragraph, then what is the
correct syntax in changing text within the paragraph?
a)
para1.value="New Text";
b)
"New Text"?
c)
para1.nodeValue="New Text";
Answer: a
22.JavaScript entities begin with the _______ and end with the _________. a)
Semicolon, colon
b)
Ampersand, colon
c)
Ampersand, semicolon
Answer: c
23.Which best describes the JavaScript?
a)
a scripting language precompiled in the
browser.
b)
a compiled scripting language.
c)
an object-oriented scripting language.
Answer: b
24.Choose the JavaScript object server-side?
a)
File
b)
Date
c)
FileUpLoad
Answer: a
25.Choose the client-side JavaScript object?
a)
Database
b)
Client
c)
FileUpLoad
Answer: c
26.Which is not considered as a JavaScript operator?
a)
New
b)
Delete
c)
This
Answer: c
27. ______method evaluates the string of the JavaScript code in
context of the specified object.
a)
Eval
b)
Efloat
c)
ParseFloat
Answer: a
28.Event fires when form element loses the focus:
<button>, <input>, <label>, <select>, <textarea>?
a)
Onfocus
b)
Onblur
c)
Onclick
Answer: b
29.The syntax of the Eval is?
a)
[objectName.]eval(numeriC.
b)
[objectName.]eval(string)
c)
[EvalName.]eval(string)
Answer: b
30.JavaScript is interpreted by the?
a)
Server
b)
Client
c)
Object
Answer: b
31.In testing specific condition, you will use ___ statement.
a)
Select
b)
For
c)
Switch
Answer: c
32.Which is structure of the if statement?
a)
if (conditional expression is true)
thenexecute this codeend if
b)
if (conditional expression is true) {then
execute this code>->}
c)
if (conditional expression is true)execute
this codeend if
Answer: b
33.How you create Date object in the JavaScript?
a)
dateObjectName Date([parameters])
b)
dateObjectName = new Date([parameters])
c)
dateObjectName := new Date([parameters])
Answer: b
34._______ method of the Array object adds and/or removes
elements from the array.
a)
Reverse
b)
Splice
c)
Slice
Answer: b
35.In setting up window to capture click events, what do you
use?
a)
window.captureEvents(Event.CLICK);
b)
window.handleEvents (Event.CLICK);
c)
window.routeEvents(Event.CLICK );
Answer: a
36.Which tag can handle the mouse events in the Netscape?
a)
<A>
b)
<BR>
Answer: a
37. ____________ is tainted property of window object.
a)
Pathname
b)
Host
c)
Defaultstatus
Answer: c
38.In enabling data tainting, end user sets ____ environment
variable.
a)
ENABLE_TAINT
b)
NS_ENABLE_TAINT
c)
ENABLE_TAINT_NS
Answer: b
39.In JavaScript, the
_________ is object of target language data type enclosing the object of
source language.
a)
a form
b)
a wrapper
c)
a cursor
Answer: b
40.When the JavaScript object is being sent to the Java, the
runtime engine will create a Java wrapper of what type?
a)
ScriptObject
b)
JavaObject
c)
JSObject
Answer: c
41.The _______ class is
providing interface that invokes JavaScript methods as well as examining JavaScript
properties.
a)
ScriptObject
b)
JSObject
c)
Jobject Answer: b
42.The _________ is a
wrapped Java array that accessed from JavaScript code.
a)
JavaPackage
b)
JavaArray
c)
JavaObject
Answer: b
43.The ________ object is reference to 1 of classes in the Java
package like netscape.javascript .
a)
JavaClass
b)
JavaPackage
c)
JavaObject
Answer: a
44.JavaScript exception is available to Java code as instance
of?
a)
netscape.javascript.JSObject
b)
netscape.plugin.JSException
c)
netscape.javascript.JSException
Answer: c
45.To automatically open console if a JavaScript mistake occurs
which is added to the prefs.js?
a)
user_pref("
javascript.console.open_on_error", false);
b)
user_pref("javascript.console.open_on_error",
true);
c)
user_pref("javascript.console.open_error
", false);
Answer: c
46.In order to open the dialog box every time a mistake occurs, which is added to prefs.js?
a)
user_pref("javascript.classic.error_alerts",
true);
b)
user_pref("javascript.console.open_on_error
", false);
c)
user_pref("javascript.classic.error_alerts
", false);
Answer: a
47.Syntax of the blur method in the button object is?
a)
Blur(value)
b)
Blur()
c)
Blur(depth)
Answer: b
48.Syntax of the capture events method for a document object is?
a)
captureEvents()
b)
captureEvents(args eventType)
c)
captureEvents(eventType)
Answer: c
49.Syntax of the close method for a document object is?
a)
Close(doC.
b)
Close(object)
c)
Close()
Answer: c
50.<script
type="text/javascript"> x=4+"4"; document.write(x);
</script> the output is ?
a)
4
b)
8
c)
44
Answer: c
51.It is possible to nest functions in the JavaScript?
a)
True
b)
False
Answer: a
52.<script>
document.write(navigator.appCodeName); </script>
a)
get code name of the browser of a visitor
b)
set code name of the browser of a visitor
Answer: a
53.Scripting language are?
a)
High Level Programming language
b)
Machine level programming language
Answer: a
54.Which explains
getSelection()?
a)
Returns VALUE of a selected OPTION..
b)
Returns value of cursor-selected text
c)
Returns VALUE of a checked radio input
Answer: b
55.Choose the client-side JavaScript object:
a)
Database
b)
Cursor
c)
FileUpLoad
Answer: c
56.Define the meaning of
"this" keyword in the javascript?
a)
It refers to the current object
b)
It’s variable containing value
c)
It refers to the previous object
Answer: a
57.In JavaScript,
Window.prompt() method return true or false value ? a)
False
b) True
Answer: a
58.<script
language="javascript"> function x()
{
document.write(2+5+"8");
}
</script>
a)
258
b)
Error
c)
7
d)
78
Answer: d
59.<script
type="text/javascript"> var s = "9123456 or 80000?"; var
pattern = /\d{4}/; var output = s.match(pattern); document.write(output);
</script>
a)
9123
b)
91234
c)
80000
Answer: a
60.Test
and tags are not displayed directly on page are written in _____ section.
a)
<html>
b) <head>
c)
<title>
d) <body>Answer:
b
61.Which
tag inserts a line horizontally on web page?
a)
<hr>
b) <line>
c)
<line direction=”horizontal”>
d) <tr>
Answer: a
62.What
should be the first tag in the HTML document?
a)
<head>
b) <title>
c)
<html>
d) <document>
Answer: c
63.The JDBC-ODBC bridge allows _______to be used as________.
a) ODBC
drivers, JDBC drivers
b) Application,
drivers
c) ODBC
drivers, JDBC drivers
d) drivers,
application
Answer: c
64. Which is true about Java.
a)
Java doesn’t support the overloading.
b)
Java has replaced the destructor function
of the C++
c)
There are no any header files in the Java.
d)
All of the above.
Answer: d
65. ______are not machine instructions and the
Java interpreter generate machine codes that is directly executed by machine
running the Java program.
a)
Compiled Instructions
b)
Compiled code
c)
byte code
d)
Java mid code Answer: c
66. The command javac
a)
Converts the java program to binary code
b)
Converts the java program to bytecode
c)
Converts the java program to machine language Answer: b
67. Which is not primitive type of Java
a)
Float
b)
Byte
c)
Character
d)
Long double
Answer: d
68.Command to execute compiled java program is?
a)
java
b)
run
c)
javac
d)
javaw
Answer: a
69.Java Servlet?
i) is key
component of server side java development ii) is a small pluggable extension to
a server that enhances functionality iii) runs only in Windows Operating System
iv) allows developers to customize any java enabled server a) i, ii & iii are ture
b)
i, iii & iv are true
c)
ii, iii & iv are true
d)
i, ii & iv are true() Answer: d
70.Inner classes are?
a)
anonymous classes
b)
nested classes
c)
sub classes
d)
derived classes Answer: b
71.How many times does code segment execute
int x=1,
y=10, z=1; do{y--; x++; y-=2; y=z; z++} while (y>1 && z<10);
a)
1
b)
10
c)
5
d)
infinite Answer: a
72.State if the
statement is true or false for EJB.
1. EJB exists
in the middle-tier()
2. EJB
specifies an execution environment3. 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
Answer: a
73.Prepared
statement object in the JDBC is being used to ins executing ____ queries.
a)
Executable
b)
simple
c)
high level
d)
parameterized
Answer: d
74. In JDBC, ____ imports all Java classes that is concerned
with the database connectivity.
a)javax.sql.*
b)java.mysql.*
c)java.sql.*
d) com.*
Answer: c
75. MS-SQL is storing data in _____ file format.
a) .DAT
b) .MDB
c) .MSSQL
d) .OBJ
Answer: a
76.
Ingres is a?
a) Socket
b) Compiler
c) Database
d) Web
serverAnswer: c
77.
In Java servlet method init( ) is
called ______ times.
a) 1
b) 2
c) 0
d) multipleAnswer:
a
78.
State if it is true or false for Java Program.
i) All class
variables are instance variables ii) All protected methods are friendly methods
a) i-false, ii-false
b) i-false,
ii-true
c) i-true,
ii-false
d) i-true,
ii-true
Answer: b
79.
State true or false for Java
Program.
i) Data
members of an interface are by default final ii) An abstract class has
implementations of all methods defined inside it. a) i-false, ii-false
b) i-false,
ii-true
c) i-true,
ii-false
d) i-true,
ii-trueAnswer: c
80.
The _____ of remotely accessible
object should implement?
a) all methods,
RemoteException
b) class,
RemoteException
c) class,
RemoteInterface
d) all methods,
RemoteInterfaceAnswer: c
81.
The ____is the key to______.
a) Serialization,
persistence
b) Persistence,
inheritance
c) Inheritance,
object
d) Persistence,
serializationAnswer: a
82.
A method name myMethod( ) that needs
2 integer arguments is declared as?
a) public void
myMethod( );
b) public void
myMethod(int a, int b);
c) public void
myMethod(int a, b);
d) public int
myMethod(a, b);Answer: b
83. JSP embeds in_____ in _____.
a) Servlet,
HTML
b) HTML, Java
c) HTML,
Servlet
d) Java, HTML
Answer: d
84.
The class at top of the exception
class hierarchy is?
a) ArithmeticException
b) Throwable
c) Class
d) ExceptionAnswer:
b
85. In the java
program, the package declaration ____ import statements. a) must
precede
b) must succeed
c) may precede
or succeed
d) none
Answer: a
86.
Class string belongs to the
____package.
a) java.awt
b) java.lang
c) java.applet
d) java.stringAnswer:
d
87.
______package is being used by the
compiler itself. So, it doesn’t need to be imported for use.
a) java.math
b) java.awt
c) java.applet
d) java.langAnswer:
d
88. State if it is true or
false.
i) Java
beans slow down software development process. ii) Java Servlets does not have
built in multithreading feature. a) i-false, ii-false
b) i-false,
ii-true
c) i-true,
ii-false
d) i-true,
ii-trueAnswer: a
89. State if it is true or false.
i) init( )
of servlet is called after a client request comes in ii) Servlets are
ultimately converted into JSP a) i-false, ii-false
b) i-false,
ii-true
c) i-true,
ii-false
d) i-true,
ii-true
Answer: a
90. What will be the result of compiling following code.
public class MyClass{
public static void main(String args[]){ System.out.println("In first
main()");
}
public static void main(char
args[]){
System.out.println('a');
}
}
a) Code will
not compile and will give "Duplicate main() method declaration" error
b) Code will
compile correctly but will give a runtime
exception
c) Code will
compile correctly and will print "In first main()" (without quotes)
when it is run
d) Code will
compile correctly and will print "a" (without quotes) when it is
runAnswer: c
91. Match the following.
a) Java 1) is a tool for
debugging java program
b) Javah 2) is a tool for creating
C-like header files
c) Javap 3) runs java bytecode
d) jdb 4) prints java code representation
a) a-3, b-2,c-1
b) a-3, b-2,
c-4, d-1
c) a-1, b-2,
c-3, d-4
d) a-2, b-1,
c-3, d-4
Answer: b
92. State if it is true or false.
i) init() is
called after start() in applet ii) applets are used for networking iii)
inheritance is a part of Java Foundation Classes iv) final does not prevent
inheritance a) i-true, ii-true, iii-false, iv-true
b) i-false,
ii-false, iii-false, iv-false
c) i-true,
ii-true, iii-true, iv-true
d) i-true,
ii-false, iii-false, iv-false
Answer: b
93.
The ____and the ____classes are
abstract classes supporting reading and writing of the byte streams.
a) reader,
writer
b) inputstream,
outputstream
c) objectinputstream,
objectoutputstream
d) none
Answer: b
94.
What is error in the code?
class Test
{
abstract void display( ); }
a) No error
b) Method
display( ) should be declared as static
c) Test class
should be declared as abstract
d) Test class
should be declared as public
Answer: c
95.
A package is a collection of?
a) classes
b) interfaces
c) editing
tools
d) classes and
interfaces
Answer: d
96.
Which methods belong to string
class?
a) length( )
b) compare To (
)
c) equals ( )
d) All of them
Answer: d
97.
What is the output of the code?
byte x=64, y; y= (byte) (x<<2); System.out.println(y);
a) 0
b) 1
c) 2
d) 64
Answer: a
98. If m and the n are int type variables, what is result of the
expression
m%n
when m=5 and n=2 ? a) 0
b) 1
c) 2
d) None of the
above
Answer: b
99. Which of the control expressions are valid when it comes to
if statement?
a) An integer
expression
b) A Boolean
expression
c) Either A or
B
d) Neither A
nor B
Answer: b
100.
The concept
of the multiple inheritance is being implemented in the Java by?
a) extending
two or more classes
b) extending
one class and implementing one or more interfaces
c) implementing
two or more interfaces
d) both b and c
Answer: b
Comments
Post a Comment
If you have any query, please let us know