Core Java Interview Questions – Set 01

Learn About Java Technology

To date, the Java platform has attracted more than 6.5 million software developers. It’s used in every major industry segment and has a presence in a wide range of devices, computers, and networks. Java technology’s versatility, efficiency, platform portability, and security make it the ideal technology for network computing. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!

Java powers more than 4.5 billion devices including:

  • 800+ million PCs
  • 2.1 billion mobile phones and other handheld devices (source: Ovum)
  • 3.5 billion smart cards
  • Set-top boxes, printers, Web cams, games, car navigation systems, lottery
    terminals, medical devices, parking payment stations, and more.

How does a 3 tier application differ from a 2 tier one?

Tiers are the physical units of separation or deployment, while layers are the logical units of separation.

Imagine that you’re designing an e-commerce website. A 3 tier architecture would consist of web pages, a web server and a database, with the corresponding 3 layers being the “Presentation”, “Business Logic” and “Database” layers.
If you take the database tier and layer out then your have a 2 tier architecture.

What is the difference between web server and app server?

A Web server exclusively handles HTTP requests, whereas an application server serves business logic to application programs through any number of protocols.

How does the version control process works?

Initiate, pull, branch, merge, commit, push.

(Init) Make your own repository. (Pull) Download an existing repository from a url. (Branch / Merge )Make revisions. Commit then push your modifications.

What is the difference between JDK and JRE?

Java Development Kit (JDK) is the most widely used Java Software Development Kit. Java Runtime Environment (JRE) is an implementation of the Java Virtual Machine which executes Java programs.

What is the difference between JAR and WAR files?

JAR files (Java ARchive) allows aggregating many files into one, it is usually used to hold Java classes in a library.

WAR files (Web Application aRchive) stores XML, java classes, and JavaServer pages for Web Application purposes.

What is the difference between equals() and “==” ?

Equals is intended to check logical equality and == checks if both references point to same object. (Thanks Sandeep)

a == b;// Compares references, not values.

a.equals(b);// Compares values for equality.

Number the bits, used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?

Unicode requires 16 bits

ASCII require 7 bits. but 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.

Define reflection

Reflection allows program related access to information about the fields, methods and constructors of loaded classes

It use reflected fields, methods, and constructors

It helps to operate on their underlying counterparts on objects

It operates within security restrictions.

Difference between javascript and program

Difference between script and program:

1. A program has well defined structure, which must be followed even execute a single file. A script is a set of instructions (may be a single statement), which are complete in it-self. And execute independently as rest of the instructions.

2. Script is loose-type. It means variable’s data-type is not must. In scripting language, variables can be used without declaring them. And its type is defined when values are assigned to them. That is loose-type. Program is strong-type. It means variable’s data-type must be declared. In programming language,
variables cannot be used without declaring them. When data-type of variable is declared, then it accepts only that type of value.

3. Programs are generally compiled, so we need compiler. And scripts are generally interpreted, so we need interpreter. Interpreter is by default available in web-browsers.

What is the purpose of the enableEvents() method

The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event.

The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.