276). Rhino is originated by _______
[A]Microsoft
[B]Mozilla
[C]Apple
[D]Chrome
Show Answer
Correct Answer: Mozilla
Notes:
Answer: b
Explanation: Rhino is a JavaScript engine written fully in Java and managed by the Mozilla Foundation as open source software. Rhino is free software from Mozilla. You can download a copy from http://www.mozilla.org/rhino/.
277). Which of the following are global functions that are not part of core JavaScript?
[A]spawn(f);
[B]trim();
[C]exult();
[D] eval()
Show Answer
Correct Answer: spawn(f);
Notes:
Answer: a
Explanation: The spawn(f) runs f() or loads and executes file f in a new thread.
278). Which of the following reads the textual contents of a URL and returns as a string?
[A] spawn(f);
[B] load(filename,…);
[C] readFile(file);
[D]readUrl(url);
Show Answer
Correct Answer: readUrl(url);
Notes:
Answer: d
Explanation: Rhino defines a handful of important global functions that are not part of core JavaScript in which readUrl(url) reads the textual contents of a URL and return as a string.
279). Which Rhino command quits Rhino environment?
[A]terminate()
[B]exit()
[C] quit()
[D]close()
Show Answer
Correct Answer: quit()
Notes:
Answer: c
Explanation: quit() is a predefined command in rhino. The quit() command makes Rhino exit.
280). Which is a useful way to try out small and simple Rhino programs and one-liners?
[A]Starting an interactive shell
[B]Starting a one to one shell
[C]Creating a thread to do simple programs
[D]Starting a multiple shell
Show Answer
Correct Answer: Starting an interactive shell
Notes:
Answer: a
Explanation: Rhino is distributed as a JAR archive. Start it with a command line like this :
java -jar rhino1_7R2/js.jar program.js
If you omit program.js, Rhino starts an interactive shell, which is useful for trying out simple programs and one-liners.
281). Which is a more formal way of importing packages and classes as JavaScript objects?
[A] import(java.util.*);
[B]importClass(java.util.*);
[C]import.Class(java.util.*);
[D]Class.import(java.util.*);
Show Answer
Correct Answer: importClass(java.util.*);
Notes:
Answer: b
Explanation: Because packages and classes are represented as JavaScript objects, you can assign them to variables to give them shorter names. But you can also more formally import them, if you want to:
282). What will be the output of the following JavaScript code?
var f = new java.io.File("/tmp/test");
var out = new java.io.FileWriter(f);
out instanceof java.io.Reader
[A]Error
[B]True
[C]Exception
[D]False
Show Answer
Correct Answer: False
Notes:
Answer: d
Explanation: The output for the above code snippet is false as it is a writer and not a Reader.
283). What does Rhino do when the getter and setter methods exist?
var f = new java.io.File("/tmp/test");
var out = new java.io.FileWriter(f);
out instanceof java.io.Reader
[A]It becomes JavaScript properties
[B]Java classes are used to avoid them
[C]Java classes & JavaScript properties
[D]It act as javascript function
Show Answer
Correct Answer: It becomes JavaScript properties
Notes:
Answer: a
Explanation: Rhino allows JavaScript code to query and set the static fields of Java classes and the instance fields of Java objects. Java classes often avoid defining public fields in favor of getter and setter methods. When getter and setter methods exist, Rhino exposes them as JavaScript properties.
284). The JavaScript classes can be instantiated using _____ operator.
var f = new java.io.File("/tmp/test");
var out = new java.io.FileWriter(f);
out instanceof java.io.Reader
[A]create
[B]new
[C]instantiate
[D]create.new
Show Answer
Correct Answer: new
Notes:
Answer: b
Explanation: New is a keyword in JavaScript which is used to define new models. New operator is used to create new instance of the class.
285). The new Java arrays can be created into JavaScript programs using which of the following classes?
var f = new java.io.File("/tmp/test");
var out = new java.io.FileWriter(f);
out instanceof java.io.Reader
[A]java.Array
[B] java.lang.*
[C] java.lang.Array
[D]java.lang.reflect.Array
Show Answer
Correct Answer: java.lang.reflect.Array
Notes:
Answer: d
Explanation: There is no natural JavaScript syntax that Rhino can extend to allow JavaScript programs to create new Java arrays, so you have to do that using the java.lang.reflect.Array class.
286). What will be the output of the following JavaScript code?
Show Answer
Correct Answer: 1
Notes:
Answer: a
Explanation: Math.sin function evaluates the sine value of a particular input.
Math.PI function generates a value of 3.14.
287). What will be the output of the following JavaScript code?
[A] -4.5
[B]4.5
[C]0
[D]Error
Show Answer
Correct Answer: 4.5
Notes:
Answer: b
Explanation: The Math.abs method returns the absolute positive value of the argument passed to it. The above code will hence generate an output of 4.5.
288). What will be the output of the following JavaScript code?
Show Answer
Correct Answer: -200
Notes:
Answer: c
Explanation: Math.min() returns the lowest value in a list of arguments. The lowest value is -200, hence the output will be -200.
289). What will be the output of the following JavaScript code?
Show Answer
Correct Answer: 4
Notes:
Answer: b
Explanation: Math.floor(x) returns the value of x rounded down to its nearest integer. The value is decreased in the decimal is removed.
290). What will be the output of the following JavaScript code?
Show Answer
Correct Answer: 7
Notes:
Answer: b
Explanation: Math.sqrt function returns the square root of the argument passed to it. It is found in the math library of Javascript.