java interview questions

Get Technical Answers for Java Interview Questions by Java Developer experts, Advanced Technical Questions for Freshers and Experience Persons. Get Free practical tests.

1. What is a Local variable and the instance variable?

Ans:

A local variable is a variable that can be defined inside a method and the scope of that variable is accessible only to its method but not outside the method. An

instance variable is a variable which is defined inside a class and outside a method and the scope of that variable is accessible all throughout the class.

2. Why pointers not used in Java?

Ans: Pointers increases the complexity of a program and becomes unsafe. Hence the java code is designed with simplicity by avoiding the pointers that will become contradicting. JVM is responsible for implicit memory allocation, thus in order to avoid direct access to memory by the user,  pointers are discouraged in Java.

3. Explain the features in Java.

Ans: The features are.

The concepts of OOPs that include

  • Object-oriented
  • Inheritance
  • Encapsulation
  • Polymorphism
  • Abstraction
  1. Platform Independent - A single program runs on different platforms without any modifications.
  2. High Performance - JIT (Just in Time compiler) enables high performance which converts the bytecode into machine language and then JVM starts the execution.
  3. Multi-threading - Thread is a flow of execution. JVM creates a thread that is called the main thread. A user can able to create multiple threads by extending the thread class or by implementing the Runnable interface.

4. What are the main concepts of OOPs in Java?

Ans: The concepts of OOPs are:

Inheritance: It is a process by which one class acquires the properties of another class.

Encapsulation: It is a mechanism of wrapping the code and data as a single unit.

Abstraction: It is a methodology for hiding the implementation details and proving only the functionality to the users. 

Polymorphism: It is the ability of a variable, function or object to take multiple forms.

5. Explain the difference between Public and Private access specifiers.

Ans: Members are the methods and instance variables.

Public: These members are visible in the same package as well as in the outside packages of other packages.


Public


Here the public members in Class A are visible to Class B of the same package 1 as well as Class C of a different package 2.

Private: These members are visible only in the same class but not in the other classes of the same package or classes in the outside packages.


Private


Here the private members in class A are visible only in that class. It is invisible for class B of same package 1 as well as class C of different package 2.

6. Explain the difference between Default and Protected access specifiers.

Ans: 

Default: The default specifiers are those in which the methods and variables are declared in a class without any access specifiers.


Default


Default members in Class A are visible to the other classes which are inside the same package 1 and it is invisible to the classes which are outside the package 2. The members in Class A are visible to the Class B and invisible to the Class C.

Protected: The protected specifier is the same as a default specifier but when a class is extended than it is also visible even in a class which is outside the package.


Protected


Here the members in class A are visible in Class B of the same Package 1. For Class C of different Package 2, these members are invisible but if Class C extends Class A than these members becomes visible in Class C even outside the package 2.

7. What is the difference between the break and continue?

Ans: 

Break:

  • It can be used in switch and loop statements such as for, while, do-while.
  • The moment the break is executed it will terminate the switch or loop statements.
  • It immediately terminates the innermost enclosing loop or switch statements.

Example:

for (int i = 0; i < 10; i++)

{

if (i == 5)

{

break;

}

System.out.println(i);

}

Continue: 

  • It can be used only in loops statements.
  • It will not terminate the loop but it causes the loop to jump to the next iteration.
  • A continue within a loop nested with a switch will cause the next loop iteration to execute
Example:

for (int i = 0; i < 10; i++)

{

if(i == 5)

{

continue;

}

System.out.println(i);

}

8. What is the final keyword in Java?

Ans: The final keyword is used as a non-access modifier. A final variable is used in different contexts of a class, method and a variable.

  • Final variable: Once if any variable is assigned with a final keyword than that value of that variable cannot be modified and remains unchanging. If in case the final variable is assigned without any value than by using only the class constructor a value can be assigned to it.
  • Final method: When the method is declared as final then it cannot be overridden by the inheriting class.
  • Final class: When a class is declared as a final then it cannot be extended by any sub-class but it can able to extend the other class.

9. What is Constructor?

Ans: 

  • A constructor is a method which has the same name as that of a class.
  • When a new object is created in a class than the constructor is invoked by that corresponding class.
  • If a user doesn’t create a constructor implicitly than a default constructor is created.
  • A constructor can be overloaded.
  • If a user creates a parameterized constructor than that user should create another constructor without any parameters explicitly.

10. What is the difference between methods and constructors in Java?

Ans: 

Methods:

  • Methods are used to represent the behaviour of an object.
  • Should have the return type.
  • Methods must be invoked explicitly.
  • The compiler doesn’t provide any default method.
  • Method name may be or may not be the same as a class name.

Constructors:

  • Constructors are used in initializing the state of an object.
  • The constructor method will not have any return type.
  • The methods are invoked implicitly.
  • The compiler provides a default constructor when a class doesn’t contain any.
  • The method name of a constructor will be the same as a class name.

11. What Is Binary Number System?

Ans: Every number system uses positional notation, i.e., each position in which a digit is written has a different positional value. Each position is power of the base, which is 2 for binary number system, and these powers begin at 0 and increase by 1.

The value of a binary number is based on the presence of 1 bits and their positional value. So, the value of a given binary number is:

1 + 2 + 4 + 8 +16 + 32 + 64 + 128 = 255

which is same as 28 - 1.

12. What Is Hexadecimal Number System?

Ans:

  • Hexadecimal number system uses base 16. The digits in this system range from 0 to 15. By convention, the letters A through F is used to represent the hexadecimal digits corresponding to decimal values 10 through 15.
  • Hexadecimal numbers in computing is used for abbreviating lengthy binary representations. Basically, hexadecimal number system represents a binary data by dividing each byte in half and expressing the value of each half-byte.

13. What Is Local Environment Setup?

Ans: Assembly language is dependent upon the instruction set and the architecture of the processor. In this tutorial, we focus on Intel-32 processors like Pentium. To follow this tutorial, you will need :

  • An IBM PC or any equivalent compatible computer
  • A copy of Linux operating system
  • A copy of NASM assembler program
  • There are many good assembler programs, such as :
  • Microsoft Assembler (MASM)
  • Borland Turbo Assembler (TASM)
  • The GNU assembler (GAS)
  • We will use the NASM assembler, as it is :
  • Free. You can download it from various web sources.
  • Well documented and you will get lots of information on net.
  • Could be used on both Linux and Windows.

14. How To Installing Nasm?

Ans: If you select "Development Tools" while installing Linux, you may get NASM installed along with the Linux operating system and you do not need to download and install it separately. For checking whether you already have NASM installed, take the following steps −

  • Open a Linux terminal.
  • Type whereis nasm and press ENTER.
  • If it is already installed, then a line like, nasm: /usr/bin/nasm appears. Otherwise, you will see just nasm:, then you need to install NASM.
  • To install NASM, take the following steps :
  • Check The netwide assembler (NASM) website for the latest version.
  • Download the Linux source archive nasm-X.XX.ta.gz, where X.XX is the NASM version number in the archive.
  • Unpack the archive into a directory which creates a subdirectory nasm-X. XX.
  • cd to nasm-X.XX and type ./configure. This shell script will find the best C compiler to use and set up Makefiles accordingly.
  • Type make to build the nasm and ndisasm binaries.
  • Type make install to install nasm and ndisasm in /usr/local/bin and to install the man pages.

This should install NASM on your system. Alternatively, you can use an RPM distribution for the Fedora Linux. This version is simpler to install, just double-click the RPM file.

15. What Are The Assembly Program Sections?

Ans: An assembly program can be divided into three sections −

  • The data section,
  • The bss section, and
  • The text section.

16. What Is The Data Section?

Ans: The data section is used for declaring initialized data or constants. This data does not change at runtime. You can declare various constant values, file names, or buffer size, etc., in this section.

The syntax for declaring data section is: section.data

17. What Is The Bss Section?

Ans: The bss section is used for declaring variables. The syntax for declaring bss section is : section.bss

18. What Is The Text Section?

Ans: The text section is used for keeping the actual code. This section must begin with the declaration global _start, which tells the kernel where the program execution begins.

The syntax for declaring text section is:

section.text

   global _start

_start:

19. What Are The Assembly Language Statements?

Ans: Assembly language programs consist of three types of statements −

  • Executable instructions or instructions,
  • Assembler directives or pseudo-ops, and
  • Macros.

The executable instructions or simply instructions tell the processor what to do. Each instruction consists of an operation code (opcode). Each executable instruction generates one machine language instruction.

The assembler directives or pseudo-ops tell the assembler about the various aspects of the assembly process. These are non-executable and do not generate machine language instructions.

Macros are basically a text substitution mechanism.

20. What Are Memory Segments?

Ans: A segmented memory model divides the system memory into groups of independent segments referenced by pointers located in the segment registers. Each segment is used to contain a specific type of data. One segment is used to contain instruction codes, another segment stores the data elements, and a third segment keeps the program stack.

In the light of the above discussion, we can specify various memory segments as −

  • Data segment − It is represented by .data section and the .bss. The .data section is used to declare the memory region, where data elements are stored for the program. This section cannot be expanded after the data elements are declared, and it remains static throughout the program. The .bss section is also a static memory section that contains buffers for data to be declared later in the program. This buffer memory is zero-filled.
  • Code segment − It is represented by .text section. This defines an area in memory that stores the instruction codes. This is also a fixed area.
  • Stack − This segment contains data values passed to functions and procedures within the program.

21. What Are The Processor Registers?

Ans: There are ten 32-bit and six 16-bit processor registers in IA-32 architecture. The registers are grouped into three categories −

  • General registers,
  • Control registers, and
  • Segment registers.

The general registers are further divided into the following groups −

  • Data registers,
  • Pointer registers, and
  • Index registers.

22. What Are The Basic Modes Of Addressing ?

Ans: The three basic modes of addressing are −

  • Register addressing
  • Immediate addressing
  • Memory addressing

Register Addressing

In this addressing mode, a register contains the operand. Depending upon the instruction, the register may be the first operand, the second operand or both.

For example,

MOV DX, TAX_RATE ; Register in first operand

MOV COUNT, CX  ; Register in second operand

MOV EAX, EBX  ; Both the operands are in registers

As processing data between registers does not involve memory, it provides fastest processing of data.

Immediate Addressing

An immediate operand has a constant value or an expression. When an instruction with two operands uses immediate addressing, the first operand may be a register or memory location, and the second operand is an immediate constant. The first operand defines the length of the data.

For example,

BYTE_VALUE  DB  150 ; A byte value is defined

WORD_VALUE  DW  300 ; A word value is defined

ADD  BYTE_VALUE, 65 ; An immediate operand 65 is added

MOV AX, 45H; Immediate constant 45H is transferred to AX

Direct Memory Addressing

When operands are specified in memory addressing mode, direct access to main memory, usually to the data segment, is required. This way of addressing results in slower processing of data. To locate the exact location of data in memory, we need the segment start address, which is typically found in the DS register and an offset value. This offset value is also called effective address.

In direct addressing mode, the offset value is specified directly as part of the instruction, usually indicated by the variable name. The assembler calculates the offset value and maintains a symbol table, which stores the offset values of all the variables used in the program.

In direct memory addressing, one of the operands refers to a memory location and the other operand references a register.

23. What Is The Equ Directive?

Ans: The EQU directive is used for defining constants. The syntax of the EQU directive is as follows −

CONSTANT_NAME EQU expression

For example: TOTAL_STUDENTS equ 50

You can then use this constant value in your code, like −

mov  ecx,  TOTAL_STUDENTS

cmp  eax,  TOTAL_STUDENTS

The operand of an EQU statement can be an expression −

LENGTH equ 20

WIDTH  equ 10

AREA   equ length * width

Above code segment would define AREA as 200.

24. What is the difference between Abstract class and Interface?

Ans: 

Abstract class:

  • Abstract classes have a default constructor that is called when a concrete subclass is instantiated.
  • Contains both Abstract and Non-abstract methods.
  • A class that extends the abstract class doesn’t need the implementation of all methods, only abstract methods are implemented in the concrete sub-class.
  • Abstract class contains instance variables.

Interface:

The interfaces have no constructors and couldn’t be instantiated.

Only the abstract methods alone must be declared.

The classes which implement the interface should provide the implementation for all methods.

Interfaces contain only constants.



25. How Do You Take A Thread Dump Of A Java Process?

Ans: Taking thread dump is easier than taking heap dump because you don't need to remember tool. In Linux, you can just use the kill command to take the thread dump e.g.

$ kill -3 PID

will print the thread dump in the log file or where System.out is redirected. Similarly, in Windows, you can use Ctrl + Break from the command prompt. Alternatively, you can also use jConsole and VisualVM to take the thread dump of Java application in both Windows and Linux. You can also read Java Performance The Definitive Guide By Scott Oaks to learn more about thread dump and heap dump.

Java Certification Training

  • Master Your Craft
  • Lifetime LMS & Faculty Access
  • 24/7 online expert support
  • Real-world & Project Based Learning

 


26. Can you override a private or static method in java?

Ans: No. You cannot override private or static methods. If a similar method is created with the same return type and the same method arguments in child class then it hides the superclass method which is also called as method hiding. Similarly, the private method is not overridable in sub-class which is not accessible there. You can create another private method with the same name in the child class as in this example.

Example:

class Base_class {

private static void display() {

System.out.println("Static or class method from Base class");

}

public void print() {

System.out.println("Non-static or instance method from Base class");

}

class Derived_class extends Base_class {

private static void display() {

System.out.println("Static or class method from Derived class");

}

public void print() {

System.out.println("Non-static or instance method from Derived class");

}

public class test {

public static void main(String args[])

{

Base obj= new Derived_class();

obj.display();

obj.print();

}

}

27. What is the difference between Error and Exception?

Ans:

  • An error is an unrecoverable condition that occurs at runtime such as “OutofMemory” error.  These JVM errors cannot be repaired at runtime. Even though such kind of errors is caught in the catch block, the application execution will be halted and becomes unrecoverable. 
  • The exceptions are the conditions which applied for tracking the bad input to human error while executing a program. For example “FileNotFoundException” is an exception which is thrown to handle if the specified file doesn’t exist. 

28. What is the difference between Serialization and Deserialization in Java?

Ans:

Serialization:

  • The Serialization is a process of converting the objects into a byte stream.
  • An object is serialized by writing it an ObjectOutputStream.

Deserialization:

  • The Deserialization is an exact opposite of what a Serialization will process where we can get the objects back from the byte stream.
  • An object is deserialized by reading it from an ObjectInputStream.

29. When to use Runnable interface and Thread class in Java?

Ans: When a class is needed for extending some other classes other than a thread then it is recommended to implement the runnable interface because java can extend only one class. If there is no need for extending any class than at the time it is recommended to extend the properties of a thread class.

30. Explain the difference between HashMap and HashTable.

Ans: 

HashMap:

  • The methods in HashMap are not synchronized.
  • HashMap will not have thread-safety.
  • The iterator will be used for iterating the values.
  • Allows one null key and multiple null values.
  • Performs high compare to the HashTable.

HashTable:

  • The key methods in HashTable are synchronized.
  • HashTable will have thread-safety.
  • The enumerator will be used for iterating the values.
  • Doesn’t allow anything which is null.
  • Performs low compare to the HashMap.

31. What is the difference between HashSet and Treeset?

Ans: 

HashSet:

  • The elements which are inserted into HashSet will be in random order.
  • HashSet can store null objects.
  • Performance is fast.

TreeSet:

  • The elements in a TreeSet will be maintained in sorted order.
  • TreeSet cannot store null objects.
  • Performance is slow.

32. What are Collections in java?

Ans: Collections are the framework which is designed to store and manipulate the objects. The collections perform the following operations.

  • Searching
  • Sorting
  • Insertion
    Deletion
  • Manipulation.

A group of objects are known as collections. All the collection classes and interfaces are available in the util package.

33. What is the difference between Ordered and Sorted in collections?

Ans:

  • Ordered collections are values which are stored in a collection that is based on the values that are added to the collection. These values can be iterated from the collection in a specific order.
  • The sorted collection mechanism is applied internally or externally such that the group of objects sorted in a particular collection is based on the properties of objects.

34. What is the difference between Array list and Vector in Java?

Ans: 

ArrayList:

  • An Array List is not synchronized.
  • It performs fast as it’s non-synchronised.
  • The size of an array increases by 50% when an element is inserted into an Array List.
  • Array List will not define the size of increment.
  • Array List uses Iterator only for traversing.

Vector:

  • A Vector is synchronized.
  • It performs slow as it’s thread-safe.
  • By default, vector doubles the size of an array.
  • Vector will define the size of increment.
  • Vector uses both Enumerator and Iterator for traversing.

35. What is the difference between Array and ArrayList?

Ans: 

Array:

  • Arrays will not contain the values of different data types.
  • Size of an Array is defined during declaration.
  • To add data index is specified in Arrays.
  • Arrays are not parameterized type.
  • Arrays contain primitive data types as well as objects.

ArrayList:

  • ArrayList contains the values of different data types.
  • Size of ArrayList changes dynamically.
  • There is no need for specifying indexes in ArrayList.
  • ArrayLists are parameterized type. 
  • Primitive data types are not allowed in ArrayList but contain only objects.

36. What is the difference between Get and Post methods in Servlet?

Ans:

Get method:

  • Limited amount of data can be sent because the data is sent in the header section.
  • The data is exposed to a URL bar and so it is not secured.
  • It can be bookmarked.
  • It is Idempotent.
  • It is used more efficiently than a Post method.

Post method:

  • A large amount of data can be sent because the data is sent in the body section.
  • The data is secured since it is not exposed to a URL bar. 
  • It cannot be bookmarked.
  • It is not Idempotent.
  • It is used with less efficiency. 

37. What are the different methods of session management in Servlets?

Ans: Session is a state of a conversation between client and server and consists of multiple requests and responses. As HTTP and Web Server are stateless, the session maintains the unique information as session-id that is passed between client and server in every request and response. The methods of session management in servlets are:

  1. User Authentication
  2. HTML Hidden Field
  3. Cookies
  4. URL Rewriting
  5. Session Management API

38. What is a JDBC Driver?

Ans: JDBC is a software component which enables the application to interact with the database. There are mainly four types of JDBC drivers.

  1. JDBC-ODBC bridge driver
  2. Native-API driver (partially java driver)
  3. Network Protocol driver (fully java driver)
  4. Thin driver (fully java driver)

39. What are the JDBC statements?

Ans: These are the statements which are used to send SQL commands to the database and also retrieve the data from the database. The methods like execute(), executeUpdate() and executeQuery() are provided by JDBC to interact with the database.

JDBC supports three types of statements.

  1. Statement: It is a general statement which is used to access the database and execute static SQL query at runtime.
  2. PreparedStatement: It is used in providing the input parameters to the query during the execution.
  3. CallableStatement: It is used for accessing the database stored procedures and helps in accepting runtime parameters.

40. What are the lifecycle methods for a JSP?

Ans: There are three lifecycle methods in JSP

  • public void jspInit() - It is invoked only once which is same as that of init() method used in servlet.
  • public void _jspService(ServletRequest request, ServletResponse response) throws ServletException, IOException - It is invoked at each request which is same as that of service() method used in servlet.
  • public void jspDestroy() - It is invoked only once which is same as that of destroy() method used in servlet.



41. How is JSP better than a Servlet Technology?

Ans: JSP is a technology of the server’s side programming with simple content generation. JSP’s are document-centric while Servlets are programs. A JSP page contains the fragments of java programming code which executes and instantiates Java classes. However, they occur inside an HTML template file. It provides the framework for the development of a Web Application.

Subscribe to our youtube channel to get new updates..!

 


42. What is Synchronization?

Ans: Synchronization is about handling only one thread for accessing a block of code at a time. While multiple threads access the block of code then there are chances for inaccurate results, in the end, to avoid this the synchronization is provided for the sensitive block of code. The keyword “synchronized” means that a thread requires a key to access the synchronized code.

It locks as per object. Each Java object has a lock which has only one key. A thread can access a synchronized method only if the thread can get a key to the objects to lock. Towards this, the “Synchronization” keyword will be used.

Example:

public class ExampleThread implements Runnable{

 public static void main (String[] args){

 Thread t = new Thread ();

 t.start ();

 }

 public void run(){

 synchronized(object){

 {

 }

}

43. Name the different modules of Spring framework.

Ans: The modules of spring framework include.

  • Spring Context – for dependency injection.
  • Spring Web Module – for creating web applications.
  • Spring AOP – for aspect-oriented programming.
  • Spring ORM – for ORM tools support such as Hibernate
  • Spring DAO – for database operations using DAO pattern
  • Spring JDBC – for JDBC and DataSource support.
  • Spring MVC – Model-View-Controller implementation for creating web applications, web services etc.

44. Explain the role of DispatcherServlet and ContextLoaderListner.

Ans: 

  • Ans: Dispatcher Servlet is a front controller in Spring MVC application which loads the spring bean configuration file and initializes all beans which are configured. By enabling the annotations it allows scanning the packages to configure any bean annotated with @Component, @Controller, @Repository or @Service annotations.
  • ContextLoaderListner is a listener that can start and shut the “WebApplicationContext” in spring root. Its main function ties the lifecycle of Application Context to the lifecycle of the ServletContext and automating the creation of ApplicationContext.


45. Explain Some Assembly Controls?

Ans: 

  • BRA Branch; Motorola 680x0, Motorola 68300; short (16 bit) unconditional branch relative to the current program counter
  • JMP Jump; Motorola 680x0, Motorola 68300; unconditional jump (any valid effective addressing mode other than data register)
  • JMP Jump; Intel 80x86; unconditional jump (near [relative displacement from PC] or far; direct or indirect [based on contents of general purpose register, memory location, or indexed])
  • JMP Jump; MIX; unconditional jump to location M; J-register loaded with the address of the instruction which would have been next if the jump had not been taken
    JSJ Jump, Save J-register; MIX; unconditional jump to location M; J-register unchanged
  • Jcc Jump Conditionally; Intel 80x86; conditional jump (near [relative displacement from PC] or far; direct or indirect [based on contents of general purpose register, memory location, or indexed]) based on a tested condition: JA/JNBE, JAE/JNB, JB/JNAE, JBE/JNA, JC, JE/JZ, JNC, JNE/JNZ, JNP/JPO, JP/JPE, JG/JNLE, JGE/JNL, JL/JNGE, JLE/JNG, JNO, JNS, JO, JS
  • Bcc Branch Conditionally; Motorola 680x0, Motorola 68300; short (16 bit) conditional branch relative to the current program counter based on a tested condition: BCC, BCS, BEQ, BGE, BGT, BHI, BLE, BLS, BLT, BMI, BNE, BPL, BVC, BVS
  • JOV Jump on Overflow; MIX; conditional jump to location M if overflow toggle is on; if jump occurs, J-register loaded with the address of the instruction which would have been next if the jump had not been taken

46. What Is Assembly Condition Codes?

Ans: 

  • Condition codes are the list of possible conditions that can be tested during conditional instructions. Typical conditional instructions include: conditional branches, conditional jumps, and conditional subroutine calls. Some processors have a few additional data related conditional instructions, and some processors make every instruction
  • conditional. Not all condition codes available for a processor will be implemented for every conditional instruction.

47. What Is Data Movement?

Ans: Data movement instructions move data from one location to another. The source and destination locations are determined by the addressing modes, and can be registers or memory. Some processors have different instructions for loading registers and storing to memory, while other processors have a single instruction with flexible addressing modes.

48. What Are The Types Of Assemblies?

Ans: Assemblies are of two types:

  • Private Assemblies
  • Shared Assemblies

49. Explain An Intermediate Language?

Ans: Assemblies are made up of IL code modules and the metadata that describes them. Although programs may be compiled via an IDE or the command line, in fact, they are simply translated into IL, not machine code. The actual machine code is not generated until the function that requires it is called.

Java Certification Training

Weekday / Weekend Batches

 


50. What Is Assembly Language?

Ans:

  • Each personal computer has a microprocessor that manages the computer's arithmetical, logical, and control activities.
  • Each family of processors has its own set of instructions for handling various operations such as getting input from keyboard, displaying information on screen and performing various other jobs. These set of instructions are called 'machine language instructions'.
  • A processor understands only machine language instructions, which are strings of 1's and 0's. However, machine language is too obscure and complex for using in software development. So, the low-level assembly language is designed for a specific family of processors that represents various instructions in symbolic code and a more understandable form.


51. What Are The Advantages Of Assembly Language?

Ans : 

  • Having an understanding of assembly language makes one aware of:
  • How programs interface with OS, processor, and BIOS;
  • How data is represented in memory and other external devices;
  • How the processor accesses and executes instruction;
  • How instructions access and process data;
  • How a program accesses external devices.
  • Other advantages of using assembly language are:
  • It requires less memory and execution time;
  • It allows hardware-specific complex jobs in an easier way;
  • It is suitable for time-critical jobs;
  • It is most suitable for writing interrupt service routines and other memory resident programs.

52. What Are The Basic Features Of Pc Hardware?

Ans: 

The main internal hardware of a PC consists of processor, memory, and registers. Registers are processor components that hold data and address. To execute a program, the system copies it from the external device into the internal memory. The processor executes the program instructions.
The fundamental unit of computer storage is a bit; it could be ON (1) or OFF (0). A group of nine related bits makes a byte, out of which eight bits are used for data and the
last one is used for parity. According to the rule of parity, the number of bits that are ON (1) in each byte should always be odd.
So, the parity bit is used to make the number of bits in a byte odd. If the parity is even, the system assumes that there had been a parity error (though rare), which might have been caused due to hardware fault or electrical disturbance.

The processor supports the following data sizes −
Word: a 2-byte data item
Doubleword: a 4-byte (32 bit) data item
Quadword: an 8-byte (64 bit) data item
Paragraph: a 16-byte (128 bit) area
Kilobyte: 1024 bytes
Megabyte: 1,048,576 bytes

53. What Does -xmx And -xms Parameters Mean?

Ans: These are parameters to specify heap size in Java. The -Xms defines the size of the heap when JVM starts up and -Xmx is used to specify the maximum heap size for Java application i.e. your heap cannot grow beyond that and JVM will die by throwing OutOfMemoryError if your heap doesn't have enough space to create new objects. See here to learn more about heap memory in Java.

54. What Is Outofmemoryerror In Java? How Do You Deal With That?

Ans: The Java virtual machine throws java.lang.OutOfMemoryError when there is not enough memory to run the application e.g. no more memory to create new objects, no more memory to create new threads etc. The most common OutOfMemoryError is the java.lang.OutOfMemoryError: java heap space, which comes when there is no more memory left to create a new object.

55. What Is The Difference Between 32-bit And 64-bit Jvm?

Ans: The main differences between 32-bit and 64-bit JVM are that later is designed for 64-bit operating system e.g. Windows 8 or later versions of Linux. From Java developer's perspective, the main difference between them comes from heap size. A 64-bit JVM virtually has unlimited heap memory as compared to 4GB of the theoretical limit of 32-bit JVM. If your program needs more memory, better run it on 64-bit JVM with large heap space. See here to learn more about 32-bit and 64-bit JVM

Submit an interview question

Categories

Request for more information

Sachin
Sachin
Networking, OS, Salesforce & Sap
Am sachin I have worked with hkr trainings for more than 4 years .and our methodologies had been a practical suit for student culture and professionals. And I have trained more than 30 batches over the last 8 months. And I have great experience working with hkr trainings. Contact me with my LinkedIn and Twitter.

WhatsApp
To Top