0
Q:

What is the output of this program ?

class main_arguments {
            public static void main(String [ ] args)
            {
                String [][] argument = new String[2][2];
                int x;
                argument[0] = args;
                x = argument[0].length;
                for (int y = 0; y < x; y++)
                    System.out.print(" " + argument[0][y]);           
            }
        }

A) 1 1 B) 1 0
C) 1 0 3 D) 1 2 3

Answer:   D) 1 2 3



Explanation:

In argument[0] = args;, the reference variable arg[0], which was referring to an array with two elements, is reassigned to an array (args) with three elements.
Output:
$ javac main_arguments.java
$ java main_arguments
1 2 3

Subject: Java
Exam Prep: GATE
Q:

Which of the following attribute can hold the JavaScript version?

A) script B) version
C) language D) none of the above
 
Answer & Explanation Answer: C) language

Explanation:

Language attribute contains the javascript versions.

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: Analyst , IT Trainer , Software Architect

8 13069
Q:

Which of the following best describes JavaScript?

A) a scripting language precompiled in the browser. B) an object-oriented scripting language
C) a low-level programming language. D) a compiled scripting language.
 
Answer & Explanation Answer: B) an object-oriented scripting language

Explanation:

JavaScript, often abbreviated as JS, is a high-level, interpreted programming language that conforms to the ECMAScript specification.

 

JavaScript has

* curly-bracket syntax,

* dynamic typing,

* prototype-based object-orientation, and

* first-class functions.

 

Uses :

It is well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat.

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer

3 14273
Q:

Javascript is interpreted by

A) Server B) Object
C) Client D) None of the above
 
Answer & Explanation Answer: C) Client

Explanation:

JavaScript is an interpreted language, not a compiled language. A program such as C++ or Java needs to be compiled before it is run.

The source code is passed through a program called a compiler, which translates it into bytecode that the machine understands and can execute.

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: Analyst , IT Trainer

20 20141
Q:

Which is a reserved word in the java programming language?

A) Variable B) Identifier
C) Keyword D) Main
 
Answer & Explanation Answer: C) Keyword

Explanation:

Reserved words are words that cannot be used as object or variable names in a Java program because they're already used by the syntax of the Java programming language.

Java reserved words are keywords that are reserved by Java functions or other uses that cannot be used as identifiers (e.g., variable names, function names, class names).

If a reserved word was used as a variable you would get an error or unexpected result.

 

Examples : Int, Long, Abstract, Class, Break, Catch, Case, Public, Static, Void,...

 

 

Report Error

View Answer Report Error Discuss

1 1965
Q:

Difference between Arraylist and Linked list?

Answer

ArrayList and LinkedList both implements List interface and maintains insertion order. Both are non synchronized classes.


 


But there are many differences between ArrayList and LinkedList classes that are given below.


 

ArrayList    V/s     LinkedList ::


 

1) ArrayList internally uses dynamic array to store the elements.


                   Whereas


LinkedList internally uses doubly linked list to store the elements.


 

2) Manipulation with ArrayList is slow because it internally uses array. If any element is removed from the array, all the bits are shifted in memory.


                   Whereas


Manipulation with LinkedList is faster than ArrayList because it uses doubly linked list so no bit shifting is required in memory.


 

3) ArrayList class can act as a list only because it implements List only.


                   Whereas


LinkedList class can act as a list and queue both because it implements List and Deque interfaces.


 

4) ArrayList is better for storing and accessing data.


                   Whereas


LinkedList is better for manipulating data.

Report Error

View answer Workspace Report Error Discuss

3 2123
Q:

What is String Args in Java?

Answer

String Args (String []) is an array of parameters of type String.


In Java, 'args' contains the supplied command-line arguments as an array of String objects. In other words, if you run your program as 'java MyProgram Hello World' then 'args' will contain ["Hello", "World"]. When a java class is executed from the console, the main method is what is called.

Report Error

View answer Workspace Report Error Discuss

9 1990
Q:

What is Interpreter in Java?

Answer

  • An Interpreter is a program that reads in as input a source program, along with data for the program, and translates the source program step by step.


 


The Java interpreter decodes each lines bytecode and runs a series of machine instructions for that bytecode. The JVM takes the byte code and generates machine code. The byte code is compiled to machine code, and the machine code is executed.

Report Error

View answer Workspace Report Error Discuss

7 2396
Q:

When do you override hashcode and equals() ?

Answer

HashCode method return int value. So the Hash value is the int value returned by the hash function .


If you want to do equality check or want to use your object as key in HashMap, we must override hashcode and equals() method.

Report Error

View answer Workspace Report Error Discuss

Subject: Java
Job Role: Analyst , IT Trainer

5 2818