Programming





Interview Question and Answers Part 1

Interview Question and Answers Part 1


by Administrator | 30-Mar-2020
Java

Tags:  Interview  Question And Answer

Share: 


  1. Can a Java interpreter be used for the execution of the source code?

Yes

  1. On successful compilation, a file with the .class extension is created?

Yes

  1. Can a Java source code be written in Notepad editor?

Yes

  1. Is a Java Program enclosed in a class definition?

Yes

  1. What is a compilation unit?

A compilation unit is a Java Source Code file.

  1. Is Empty .java file a valid source file?

Yes, an empty .java file is a perfectly valid source file.

  1. Can a .java file contain more than one java class?

Yes, a .java file contains more than one java class, provided at the most one of them is a public class.

  1. Is Java Virtual Machine (JVM) a compiler or an interpreter?

Interpreter

  1. What is the difference between JVM Spec, JVM Implementation, and JVM Runtime?

The JVM spec is a blueprint for the JVM generated and owned by Sun Microsystems, now Oracle.

The JVM implementation is the actual implementation of the spec by a vendor.

The JVM Runtime is the actual running instance of a JVM implementation.

  1. What is a BDK?

BDK (Bean Development Kit) is a tool that enables us to create, configure and connect a set of Beans and be used to test Beans without writing code.

  1. What is the use of bin and lib in JDK?

bin contains tools such as javac, applet viewer, awt tool etc., whereas lib contains packages and variables.

  1. What are the two parts in executing a Java program and their purposes?

Two parts in executing a Java program are:

Java Compiler is used for the compilation of a Java program.

Java Interpreter is used for executing the compiled program

  1. What is the difference between PATH and CLASSPATH?

PATH is used for setting up an environment for the operating systems. The operating system will look in this PATH for executables.

CLASSPATH is used for setting up the environment for Java. Java will use the classpath to find compiled classes.

  1. What environment variables do I need to set on my machine in order to be able to run Java programs?

You’ll need to set CLASSPATH and PATH in order to be able to run Java programs.

  1. What are Java Beans?

JavaBeans is a portable, platform-independent component model written in the Java programming language. It enables developers to write reusable components once and run them anywhere-benefiting from the platform-independent power of Java technology. JavaBeans are Java classes which adhere to certain coding conventions:

  • Implements java.io.Serializable interface
  • Provides no-argument constructor
  • Provides getter and setter methods for accessing it’s properties
  1. What are the rules for defining a Java Bean class?

Must have setter & getters methods.

Must declare a public default constructor.

Implements Serializable interface.

  1. What is the difference between POJO and java bean class?

A Bean is a java class that has getter and setter methods without any logic in it. It is used for holding data.

A Java class can have everything a java Bean has as well as some logic inside it.

A bean class can be a POJO class but a POJO can’t be a Java Bean class.

  1. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?

Unicode requires 16 bits and ASCII requires 7 bits. Although the ASCII characters use only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18-bit patterns. UTF-16 uses 16-bit and larger bit patterns.

  1. What are the requirements of every Java application?

A class and the main( ) method declaration is required. The main method tells the application starting point.

  1. What is the return type of program’s main( ) method?

Void is the return type of the main method.


Comments:


There are no comments.

Enter a new Comment:










Copyright Šprgrmmng. All rights reserved.