Java Basics Interview Questions

Here are the Interview Questions covering the basics of Java,

Q1. Java was initially called what?

A1. Java was called “Oak”, and was given the name Java.


Q2. When was the initial version of Java launched and who originally developed it?

A2. Java was originally developed by James Gosling and was initially released in 1995


Q3. Define JAVA?

A3. Java is an object-oriented programming language, which is platform-independent. It was developed in 1995 and acquired by Oracle in 2010.


Q4. State the Java Versions?

A4.

Here are the Java Versions,

Java Release Release Year
JDK 1.01996
JDK 1.11997
J2SE 1.21998
J2SE 1.32000
J2SE 1.42002
J2SE 1.52004
Java SE 62006
Java SE 72011
Java SE 82014
Java SE 92017

Q5. State some applications of Java.

A5.

  • 100+ TV Devices run Java
  • 3 Billion Mobile Phones run Java
  • Game consoles
  • Refer for more: Applications of Java!

Q6. Which well-known issues of the Internet does Java solve?

A6. Portability and Security are the major issues with the Internet. Java came at the time when WWW came to light. The Internet required a portable programming language to address its issues.


Q7. State how Java solves the issue of Portability and Security.

A7. Java solves the issue of Portability and Security since the output of a Java compiler is Bytecode, not executable code.


Q8. What is Bytecode?

A8. The set of instructions designed to be executed by the Java run-time system is Bytecode. Here, the set of instructions is highly optimized and the Java run-time system is called the Java Virtual Machine (JVM).


Q9. What is Java Virtual Machine (JVM)?

A9. Java Virtual Machine (JVM) provides a runtime environment in which Java bytecode can be executed


Q10. Why a Java program is translated to Bytecode?

A10. The translation makes it easier to run a program in different environments. This is because only the JVM needs to be implemented for each platform.


Q11. Does Java support Remote Method Invocation (RMI)?

A11. Yes, Java supports Remote Method Invocation, which is a Java API. The Java RMI API performs remote method invocation i.e. enable a program to invoke methods across a network.


Q12. List some of the new features introduced in Java SE 8 (Java 8)?

A12. The new features are:

  • Lambda Expressions
  • New Stream API
  • Package java.util.function introduced.
  • New Time and Date API
  • Supports for JavaFX 8

Q13. How Java is Architecture-Neutral?

A13. Java is Architecture Neutral since it is platform-independent i.e. it follows:

write once; run anywhere, anytime, forever

A Java program does not depend on the operating system you have or the hardware, even it does not
get affected by Operating System upgrades or changes in system resources.


Q14. Which of the following would create a class file “SampleProgram.class” after execution,

1.) Compile time statement – javac SampleProgram.java

2.) Runtime statement – java SampleProgram

A14. Compile-time statement – “javac SampleProgram.java” will create a class file “SampleProgram.class”. javac is a Java Compiler that creates a class file of a java program as shown above.


Q15. The Java compiler requires that a source file use the “.java” filename extension. True or false?

A15. True, as shown in Q14 above, we compiled a file named “SampleProgram.java”


Q16. Are Java file names case-sensitive? True or False?

A16. True


Q17. A Java program begins with a call to which function?

A17. Java program begins with a call to the main() function.


Q18. What are the three styles of comments Java supports?

A18. Java supports the following three styles of comments,

  • Single-line comment
  • Multi-line comment
  • Documentation comment

Q19. What does “public” mean in the following,

A19. public is a keyword, which is an access modifier


Q20. What does “static” mean in the following,

A20. static is a keyword that allows calls main( ) method without the need to instantiate a particular instance of the class.


Q21. What is the usage of “args[ ]” parameter in the following,

A21. String args[ ] is an array of instances. Here, the args receive any command-line arguments. These arguments can be worked upon when the program is executed. For example,

          java SampleProgram.java arg1

Here, arg1 is argument one


Q22. What is System.out.println in the following sample program,

A22. Here,

  • System = predefined class
  • out = output stream
  • println = It is a method that prints messages. In this case, it prints “Our first Java Program!”

Q23. Java programs are a collection of ________?

A23. Whitespace, identifiers, literals, comments, operators, separators, & keywords


Q24. What is Whitespace?

A24. Space, tab, or newline added to a Java program is known as whitespace.


Q25. Define Identifiers?

A25. Identifiers are the name given to a class, method, and variables.
For example, temp, i, count1, count2 are all Identifiers.


Q26. Give examples of Literals in Java?

A26.  Here are three examples showing floating-point, integer, and string literals:

  • 32.7
  • 10
  • Java is awesome!

Q27. Java 8 has added two new operators? Name it?

A 27. The two new operators added in Java 8 are,
1.) :: i.e. Double Colon
2.) Lambda Expressions


Q29. Explain the usage of the Double Colon operator introduced in Java 8.

A29.  The double colon (::) operator has been added in Java 8, and used to create a reference to a method or constructor.


Q30. List some Java Keywords?

A30.  Here are some Java keywords:
Boolean, break, int, float, extends, package, this, throws, void, native, volatile, transient, etc.


Q31. Is Java a Strongly Typed language?

A31. Yes


Q32. List all the primitive types of data (data type) in Java?

A32. Here are the primitive types of data in Java: boolean, byte, int, short, long, char, float, double


Q33. Name the smallest integer type?

A33.  The byte is the smallest integer type


Q34. Which one is a signed 16-bit type,

a.) int
b.) short
c.) long

A34.  short


Q35. Which one is a signed 32-bit type,

a.) int
b.) short
c.) long

A35. int


Q36. Which type is used for huge, whole numbers? For example, 178685726876

a.) int
b.) long
c.) short

A36.  Such huge numbers could only be handled by long type.


Q37. Name the two floating-point types?

A37. The floating-point types are double and float.


Q38. When double-type is preferred over float-type?

A38.  When you need a large degree of precision and large-valued numbers, then use double-type.
For example, transcendental math functions like sin( ), cos( ), and sqrt( ), return double values.

Double-type uses 64 bits to store a value, unlike float, which uses only 32 bits to store a value.


Q39. Are chars in C/C++ are same as chars in Java?

A39.  C/C++: char is an 8-bit type.

Java: char is a 16-bit type.


Q40. State the difference between chars in Java and char in C/C++?

A40. char in Java:

  • char is a 16-bit type in Java and uses Unicode, which is a unification of characters
    sets to represent characters.
  • Range from 0 to 65,536
  • No negative chars.

          char in C/C++:

  • char is an 8-bit type in  C/C++ and the characters are represented by ASCII,
  • Range from -128 to 127 or 0 to 255

Java Interview Questions and Answers
Java Operators Interview Questions
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

1 Comment
  • Manoj Kumar jena
    Posted at 00:44h, 28 November Reply

    im vary happy for solving many simple quastion..
    Thank u for spending valuable time..
    And actually upload many quiz quastions….
    thank you
    Manoj kumar jena
    from-Odisha

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading