JavaMoreSemester ExamsSemester ExamsUncategorized

15 Most important questions from Java(Introduction)

Here are some important questions from the java, which introduce you to the basic of java

1. What is the difference between Array and vector?

Ans: 

  • Vector is growable and shrinkable whereas an Array in not.
  • Vector implements the List interface whereas an array is a primitive data type.
  • Vector is synchronized whereas an array is not.

2. What is casting?

Ans:  There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values. Casting between object reference is used to refer to an object by a compatible class, interface, or array type reference.

3. What is the difference between break and continue?

Ans: The break keywords halts the execution of the current loop and forces control out of the loop.

The continue is similar to break, except that instead of halting the execution of the loop, it starts the next iteration.

4. What is inheritance?

Ans: Inheritance allows a class to use the properties and methods of another class.  In other words, the derived class inherits the states and behaviors from the base class. The derives class is also called subclass and base class is also known as super-class.

5. List any three common runtime errors.

Ans: Few examples scenarios causing Java Runtime Errors are :

Divide an integer by Zero.

Access an element that is out of bounds on an array.

Cast an instance of the base class to one of its derives classes.

6. Java program can be possible without main method?

Ans: It is possible to compile a Java program without a main method, provided that class is used as a superclass. However, the program will execute only when there4 is a valid main method in the class.

7. Why is Java Architectural Neutral?

Ans: To enable a Java application to execute anywhere on the network, the compiler generates an architecture-neutral object file format, the compiled code is executable on many processors, given the presence of the Java runtime system. This is useful not only for networks but also for single system software distribution.

8. What are operators and what are the various types of operators available in Java?

Ans: Operators are special symbols used in expressions. The following are the types of operators:

  • Arithmetic operators.
  • Assignment operators.
  • Increment & Decrement operators.
  • Logical operators.
  • Bitwise operators.
  • Comparison/Relational operators.
  • Conditional operators.

9. What are the logical operators?

Ans: OR (Ι), AND (&), XOR(^), NOT(-).

10. What is the  % Operator?

Ans: % Operator is the modulo operator or remainder operator. It returns the remainder of dividing the first operand by the second operand.

11. Is &&= a valid operator?

Ans:  No . this is not a valid operator in java.

12. What is the order of precedence and associativity?

Ans: Order of precedence the order in which operators are evaluated in expressions. Associativity determines whether an expression is evaluated left-right or right-left.

13. Which Java operator is right associativity?

Ans: = Operator.

14. What is the difference between prefix and postfix of — and ++ operators?

Ans: the prefix form returns the increment or decrement operation and returns the value of the increment or decrement operation.

The postfix form returns the current value of all of the expression and then performs the increment or decrement operation on that value.

15. what are the various programming constructs?

Ans: The various programming constructs are:

Sequential.

Selection — if and switch statements.

iteration — for loop, while loop and do-while loop.


Warning: in_array() expects parameter 2 to be array, null given in /home/technome/jeeupdate.com/wp-content/themes/vmagazine-lite/inc/vmagazine-lite-functions.php on line 704

Comment here