Top 50+ HCL Interview Questions

hcl interview questions

An IT services and consulting company, HCL Technologies operates in 45 countries and is headquartered in Noida, India. It emerged as an independent company in 1991. HCL helps organisations reimagine their business for the digital age by building strategies around Analytics, Cloud, Digital, IoT, Cybersecurity, and Infrastructure. HCL is on the Forbes Global 2000 list and is one of the top 20 largest publicly-traded companies in India. This blog talks about the common HCL Interview Questions you must be well-versed with if you wish to land your dream job.

  1. HCL Recruitment Process
  2. Top HCL Interview Questions

HCL Recruitment Process

The recruitment process at HCL consists of these four main steps:

  • Written or Aptitude Assessment Round
  • Group Discussion
  • Technical Interview Round
  • HR Round

In this blog, we’ll look at some of the main HCL Interview Questions that you may face during the technical interview round.

Top HCL Interview Questions

1. What is the use of the finalize () method in Java?

finalize() method is called by the Garbage Collector before destroying any object to perform clean-up. The object which is not in use anymore is deleted by JVM-Garbage Collector, and before that finalize() method is called. finalize() method is declared in Object Class.

2. What is the use of polymorphism in Java?

The literal meaning of “poly” is many and “morph” is forms. Hence, polymorphism means something which exists in multiple forms. When it comes to programming, Polymorphism (from Greek, meaning “many forms”) is a feature that allows one interface to be used for a general class of actions, and it can be a single method that exists in multiple forms. The use of polymorphism is often justified by the phrase “one interface, multiple methods.”

It is of two types:

a.  Static polymorphism (method overriding)
b.  Dynamic polymorphism (method overloading)

class Electronics
{
public void cost()
{
System.out.println(“cost of electronics is maximum 50000”); 
}
}
class Mobiles extends Electronics
{
	public void cost()
	{
		System.out.println(“cost of electronics is maximum 20000”);
	}
	public static void main(String argos[])
	{
		Electronics e1 = new Mobiles();
		e1.cost();
	}
}

3. What is input-output (I/O) in C++?

The stream of data (byte stream) flowing from input devices is called the input stream, and the stream of data flowing from output devices is called the output stream. The input given to the system using input devices like keyboard, mouse, etc., is called input operation. The result displayed on the console or any output device like printer, monitor, etc., is called output operation. 

iostream header files contain the following objects that help perform I/O operations in C++.

  1. cout
  2. cin
  3. clog
  4. cerr

4. What are the basic OOPS concepts?

The basic concept of Object-oriented programming are:

  1. Abstraction – Highlighting the set of services by hiding internal implementation details is called abstraction. By using abstract Class and interface, we can implement abstraction
  1. Encapsulation – Encapsulation is the mechanism that binds together code and the data it manipulates and keeps both safe from outside interference and misuse.  Grouping functions and corresponding  data into a single capsule is called encapsulation
  1. Inheritance – Also called the is-a relationship. Inheritance is the process by which one object acquires the properties of another object. A class that inherits the properties of another class is called a subclass, and the base class is called a superclass. By using extends keyword, we can implement a relationship
  1. Polymorphism – The literal meaning of “poly” is many and “morph” is forms. Hence, polymorphism means something which exists in multiple forms. When it comes to programming, Polymorphism (from Greek, meaning “many forms”) is a feature that allows one interface to be used for a general class of actions. It can be a single method that exists in multiple forms.

5. Name a few languages that are based on OOPS concepts.

The languages that are based on OOPS concepts are:

  1. Java
  2. C++
  3. Python
  4. C++

6. How can you achieve multiple inheritances in Java?

When the same class/interface inherits multiple classes/interfaces, it is called multiple inheritances. Multiple inheritances in Java are not supported for classes, but multiple inheritances can be implemented using interfaces in Java.

Ex:

Interface House
{
void price();
}
Interface Villa
{
void area();
}
Class Property implements House, Villa
{
void price()
{
	System.out.println(“price of the property is high”);
}
void area()
{
	System.out.println(“max area of house is 5000 sqft”);
}
public static void main(String argos[])
{
Property p1 = new Property();
p1.price();
p1.area();
}
}

7. What are the different operating systems you have worked with? Which one do you like most and why?

Note: The answer to this question is subject to the person. Below is the answer.

I have worked with different operating systems: Windows 7, Windows 8, Windows 10, Ubuntu, Mac, etc. The OS I felt comfortable working with was Windows 10, as it is a Menu-driven and GUI-based operating system. The Interface for users is interactive and easy to learn/adapt.

8. Can a class be final?

Yes, a Class in Java can be declared as final. A final class cannot be extended, i.e., a child class cannot be created of a final class.

9. Can a class be private?

Typically, a Class cannot be declared private, but the inner or nested classes can be made private. The inner class declared as private will be accessible only within that outer Class.

10. What is the Collection framework?

Collection in Java refers to a group of Objects represented using specific data structures. The collection framework provides an architecture to work with a group of objects, and it consists of Interface and its implementations (classes) and Algorithms used to work with Collections. The Java.util package contains all the classes and interfaces for the Collection framework.

11. Can you explain how HashMap works?

HashMap is a part of the Java collection framework. It uses a technique called Hashing. It implements the map interface. It stores the data in the pair of Key and Value. HashMap contains an array of nodes, and the node is represented as a class. It uses an array and LinkedList data structure internally for storing Key and Value. 

12. What is the difference between Application context and bean factory?

Two of Spring’s most fundamental packages are the org.spring framework.beans and org.spring framework.context packages. Both these packages are used for dependency injection in the code, and the bean factory provides an advanced configuration mechanism capable of managing objects. The application context built on top of the BeanFactory adds functionalities such as easier integration with Springs AOP features, message resource handling, event propagation, and declarative mechanisms to create the ApplicationContext and optional parent contexts application-layer specific contexts such as the WebApplicationContext, among other enhancements.

In short, the BeanFactory provides the configuration framework and basic functionality, while the ApplicationContext adds enhanced capabilities to it, some of them perhaps more J2EE and enterprise-centric.  Usually, when building most applications in a J2EE environment, the best option is to use the ApplicationContext, since it offers all the features of the BeanFactory and adds to it in terms of features. The main usage scenario where you might prefer to use the BeanFactory is when memory usage is the most significant concern, i.e., You don’t need all the features of the ApplicationContext.

13. What is the difference between a constant variable and a global variable?

A constant variable is declared and initialized once with a value that cannot be changed later in the entire program. In contrast, global variables declared and initialized once outside a method/block can be accessed everywhere, and values can be updated anywhere in the entire program.

14. What do you mean by nested classes?

Nested Class refers to a way to declare a class inside another class. There will be an outer class and an inner class. When there is no chance of the existence of an object without the existence of another object, we use the inner class concept. The relationship between outer and inner Class is a has-a relationship.

Ex:

Without Bank, there can’t be an Account. So,

  class Bank
  { //outer class
 	class Account
  	{ //inner class
 	 }
  }

15. Name some software analysis & design tools?

Some of the software analysis & design tools are: –

  1. ER Diagram
  2. DataFlow Diagram
  3. Data Dictionary
  4. Decision Tables
  5. Structured English
  6. Structured Charts

16. What is the major difference between structured English and Pseudo Code?

Structured English is a simple English language with programming keywords used to describe the functionality and flow of the program. Pseudocode is also English statements but closer to programming languages used to represent the logic of the program/code.

17. What is the use of the pointer in C?

Pointers in the C programming language are variables that store addresses of other variables. Pointers can be used for: –

  1. A pointer can be used to refer to other pointers also. 
  2. It is mainly used in file handling.
  3. To access array elements: Pointers are used in traversing through an array of integers and strings. 
  4. For dynamic memory allocation
  5. Data Structures like a graph, tree, linked list, etc

Ex:

//declaring a pointer in C
int *p1;
int* p2;
int * p3;

//initializing a pointer in C
int *p1;
int value;
value = 10;
p1 = &value;

18. What are some of the differences between C & C++?

  1. C supports Procedural programming, and C++ supports procedural as well as object-oriented programming
  2.  Dennis Ritchie developed C in 1973, and Bjarne Stroustrup developed C++ in 1979.
  3. C language does not support Abstraction, encapsulation, polymorphism, and Inheritance, but C++ supports all the pillars of object-oriented programming.
  4. C is function-driven but C++ is object-driven programming.
  5. Function and operator overloading is not supported in C, but it is supported in C++
  6. Namespace features are not provided in C, but C++ has namespace features.
  7.  C does not support exception handling, but C++ supports exception handling
  8. C structures do not have access modifiers, but C++ has access modifiers

19. What are the 4 pillars of Object-oriented programming systems (OOPs)?

The four pillars of Object-oriented programming are:

  1. Abstraction – Highlighting the set of services by hiding internal implementation details is called abstraction. By using abstract Class and interface, we can implement abstraction
  1. Encapsulation – Encapsulation is the mechanism that binds together code and the data it manipulates and keeps both safes from outside interference and misuse.  Grouping functions and corresponding  data into a single capsule is called encapsulation
  1. Inheritance – Also called the is-a relationship. Inheritance is the process by which one object acquires the properties of another object. A class that inherits the properties of another class is called a subclass, and the base class is called a superclass. By using extends keyword, we can implement a relationship
  1. Polymorphism – The literal meaning of “poly” is many and “morph” is forms. Hence, polymorphism means something which exists in multiple forms. When it comes to programming, Polymorphism (from Greek, meaning “many forms”) is a feature that allows one interface to be used for a general class of actions. It can be a single method that exists in multiple forms.

20. What are aggregate functions in SQL?

An aggregate function performs the calculation on a group of values and provides a single value result. Aggregate functions are deterministic functions; they produce the same result for the given set of values. A few standard aggregate functions are: –

  1. AVG – this finds the average of given values
  2. COUNT – it counts the number of elements in the set. It considers null values as well.
  3. MAX – It finds the maximum value among a given set of elements
  4. MIN – It finds the minimum value among a given set of elements
  5. STDEV – It finds the standard deviation of the given set of elements
  6. SUM – It finds the sum of elements in the set
  7. VAR – It finds the variance of the elements in a set

21. What are constraints in SQL?

Constraints in SQL specify some set of rules that are applied to data in the table or database. If the rules are violated, the action performed on the data is aborted. Constraints can be applied to each column or a complete table. Some commonly used constraints in SQL are:

  1. NOT NULL – Columns cannot have null values
  2. UNIQUE – the values entered for each column should be distinct
  3. PRIMARY KEY – Primary Key is an attribute that uniquely identifies the row. This constraint is a combination of NOT NULL and UNIQUE
  4. FOREIGN KEY – Foreign key is an attribute that uniquely identifies the data in another table.
  5. DEFAULT –  specifies a default value for the attribute if no value is provided.
  6. CHECK – values in the column should satisfy the specified condition.

22. What do you mean by DBMS?

DBMS stands for Database Management system. It is a software system to store, manage and update the data most securely and efficiently. A database management system provides a complete architecture for the User to quickly and efficiently extract data from any form of a database.

23. What is init in Python?

“init” states “initialization”. __init__ in python is a function that is used to initialize the objects for a class. The first parameter in __init__ function is always “self” which points to the current object.

Ex:

def __init__(self, value):
	self.value = value

24. What is the role of the Domain Name System (DNS)?

Every website is connected with an IP address, a 16-digit number, and it is difficult to remember the IP address for each website. So there is a mapping between IP address and Domain names for each website.  Every domain name in the DNS will nominate a set of name servers to be authoritative for its DNS records. For example, when a Web address or URL is typed into a browser, a DNS query learns an IP address of a Web server associated with that Domain name.

25. What is the difference between C and Java?

  1. C supports Procedural programming, and Java supports object-oriented programming
  2.  Dennis Ritchie developed C in 1973, and sun microsystems developed C++ in early 1990.
  3.  C language does not support Abstraction, encapsulation, polymorphism, and Inheritance, but Java supports all the pillars of object-oriented programming.
  4.  C is function-driven but C++ is object-driven programming.
  5.  Function and operator overloading is not supported in C, but it is supported in Java
  6.  C does not support exception handling, but Java supports exception handling
  7.  C structures do not have access modifiers, but Java has access modifier
  8.  C Programming requires memory to be freed when not in use, but Java Programming garbage collection is taken care of automatically.
  9. C does not support the concept of multithreading, but Java does support it.

26. What is the difference between compiler, interpreter, and assembler?

Compilers are software that converts high-level language codes (Java Programs, C++ programs) into low-level language. The compiler converts the complete code into low-level code in a single go, but the interpreter converts high-level language into machine-level language line by line. Hence, Interpreters are slow compared to compilers. 

The assembler converts the assembly language code into machine language.

27. What is StringBuffer? How is it different from String?

A string is a sequence of characters. In the Java programming language, Strings are treated as objects. Multiple classes help to work with Strings in Java, and two of them are String Class and StringBuffer Class. The strings created using the StringBuffer class are modifiable, and the length and content of the sequence in a String can be changed through specific method calls. 

Strings created using StringBuffer are thread-safe.

Ex:

public class Example 
{
   public static void main(String args[]) 
	{
      	String s1 = new String("Great Leaning");
	StringBuffer sb1 = new StringBuffer("Great");
      	sb1.append(" Learning ");
      	System.out.println(sb1);
	System.out.println(s1);
   	}
}

28. What is the difference between hashtable and hashmap?

Hashtable and HashMap are Data structures used for storing data as a key-value pair. They use hashing techniques to decide where which key-value pair will be stored. Some of the significant differences between HashMap and HashTable are:-

  1. HashMap is not thread-safe; hence it is also not synchronized, whereas HashTable is synchronized and can be shared between multiple threads. Although HashMap can be made synchronized by using specific programming constructs in Java.
  2. HashTable does not allow any null values for key-value pairs, but HashMap allows one null value for a key and multiple null values for values in a key-value pair.
  3.  HashMap is comparatively fast.
  4.  Iterator can be used to access each element of HashMap, and for traversing over HashTable, enumeration and iterator can be used.
  5. HashMap inherits AbstractMap Class, and HashTable inherits Dictionary Class.

29. Write a small program to reverse a string.

A small program to reverse a string using the inbuilt method in Java.

public class Example
{
public static void main(String args[])
{
String s1 = “hello”;
String s2 = s1.strrev();
System.out. println(s2);
	}
}

A small program to reverse a string without using an in-built method in java.

public class Example:

{
public static void main(String args[])
{
String s1 = “hello”;
for(int i =s1.length; i>0; i - -)
{
System.out. println(s1.charAt(i));
}
	}
}

30. Can you implement a linked list?

Here the implementation of Linked List is given in Java:

import java.util.*;
class LLNode{
	int data;
	LLNode next;	
	LLNode(int data)
	{
		this.data=data;
		this.next=null;
		
	}
}
class Demo{
	LLNode head;
	LLNode insertAtPos(int key,int pos,LLNode head)
	{
		LLNode ttmp=new LLNode(key);
		if(pos==1)
		{
			ttmp.next=head;
			head=ttmp;
		}
		else
		{
			LLNode ttmp1=head;
			for(int i=1;ttmp1!=null && i<pos;i++)
				ttmp1=ttmp1.next;
			ttmp.next=ttmp1.next;
			ttmp1.next=ttmp;
		}
		
		return head;
	}
	LLNode delete(int pos,LLNode head)
	{
		LLNode ttmp=head;
		if(pos==1)
			head=ttmp.next;
		else
		{
			for(int i=1;ttmp!=null && i<pos-1;i++)
				ttmp=ttmp.next;
			ttmp.next=ttmp.next.next;
		}
		return head;
	}
	
	int length(LLNode head)
	{
		LLNode ttmp=head;
		int c=0;
		if(ttmp==null)
			return 0;
		else
		{
		 while(ttmp!=null)
			{	ttmp=ttmp.next;
				c++;
			}
		}
		return c;
	}
	void display(LLNode head)
	{
		LLNode ttmp=head;
		while(ttmp!=null)
			{System.out.print(ttmp.data+" ");
			 ttmp=ttmp.next;
			}
	}
	public static void main(String[] args)
	{
		LinkedListDemo l=new LinkedListDemo();
		l.head=null;
		Scanner in=new Scanner(System.in);
		 do
	{
 System.out.println("\n********* MENU *********");
	 System.out.println("\n1.Insert At A  Particular Pos");
	 System.out.println("\n2.Delete At a Pos");
	 System.out.println("\n3.Length");
	 System.out.println("\n4.Display");
	 System.out.println("\n5.EXIT");
	 System.out.println("\nenter ur choice : ");
	 int n=in.nextInt();
	 switch(n)
		{
		 case 1: System.out.println("\nenter the value");
			 l.head=l.insertAtPos(in.nextInt(),in.nextInt(),l.head);
			 break;
		 case 2: 
			 l.head=l.delete(in.nextInt(),l.head);
			 break;
		 case 3: 
			System.out.println(l.length(l.head));
			 break;
		 case 4: 
			l.display(l.head);
		 		 break;
		 case 5: System.exit(0);
		 		 break;
		 default: System.out.println("\n Wrong Choice!");
		 		  break;
		}
	 System.out.println("\n do u want to cont... ");
	}while(in.nextInt()==1);

 }
}

31. What are threads?

In Operating systems, Threads are lightweight processes. They are called lightweight because they are fast and use fewer resources to execute than a process. A thread is created when processes are divided into smaller execution units, and each execution unit refers to a thread. Multiple threads can be executed parallelly to complete a task. The switch time between threads is significantly less that it looks like they are executing parallely on a single processor. The process of executing multiple threads simultaneously is called multithreading.

32. What is a pass by reference? How is it different from a pass-by-pointer?

PASSING VARIABLES BY POINTERPASSING VARIABLES BY REFERENCE
It creates a pointer that stores the memory address of a variableCreates another variable that points to the same variable
The dereferencing operator * gives the value of the variableValue can be implicitly referenced using the variable name.
Can point to nullIt has to be initialized during the declaration
The variable can be reassigned to another memory locationIt can’t be reassigned to another memory address
Uses ‘&’ to reference the address of a variable  

33. What is the difference between overloading and overriding?

Method Overloading

Two methods have the same name, but different arguments are called overloaded methods. Method overloading is also called static polymorphism.

Ex:

class Calculations
{
	void sum(int a, int b)
	{
		System.out.println(“sum of numbers are ”+(a+b));
}
 void sum(float a, float b)   //overloaded method sum
	{
		System.out.println(“sum of numbers are ”+(a+b));
}
public static void main(String args[])
{
Calculations c = new Calculations();
c.sum(4,8);
c.sum(3.5, 6.89);
}
}

Method Overriding

Method overriding is an object-oriented language feature that allows a subclass or child class to provide a specific implementation of a method already provided by one of its superclasses or parent classes.

In inheritance, whatever the parent has is by default available to the child. Child class has the flexibility to redefine based on its specific required way.

Ex:

 class Electronics
{
public void cost()
{
System.out.println(“cost of electronics is maximum 50000”); 
}
}
class Mobiles extends Electronics
{
	public void cost()
	{
		System.out.println(“cost of electronics is maximum 20000”);
	}
	public static void main(String argos[])
	{
		Electronics e1 = new Mobiles();
		e1.cost();
	}
}

34. What is a function pointer?

When we create a function, its code always resides in memory. We can point to that memory using a pointer, which is called a function pointer. The function pointer points to the function’s code, not data of type int, float, char, etc.

Ex:

int (*p1) (int , int);    // Declaration of a function pointer, “p1”
int sum( int , int );    // Declaration of  function, “sum”
p1 = sum;          // Assigning address of “sum” function to the p1 pointer.  

35. Can you explain about virtual functions?

A Virtual function is a function declared or defined in the base class, but its implementation can be redefined again in the derived class. The virtual function can be overridden.

Ex:

#include <iostream>
using namespace std;

class BaseClass {
public:
   	virtual void sum();   // Virtual function
};
void BaseClass::sum() {
  	 cout << "sum function of base class\n";
}

class DerivedClass : public BaseClass {
public:
  	 void NameOf();   // Virtual function
};

void DerivedClass::sum() {
   	cout << "sum function of derived class";
}
int main()
{
//call the functions from here to execute them
DerivedClass d1;
DerivedClass *pD = &d1;
BaseClass    *pB = &d1;

pB->sum();  
pD->sum();      
}

36. If you have a class TestSample, how many constructors can you create?

There is no limit on the number of constructors created for any given class. Any number of constructors can be created such that each constructor should have different parameters. 

37. What is the static keyword?

The static is a modifier in Java Programming, and the static modifier is applicable only for variables, inner classes, and methods. Static variables are created once at the class level and shared by every Class object, and we can access static variables and methods directly from static areas.

Static methods can be called without using an object.

38. Explain the different types of data in C or explain the differences between basic and derived data types in C.

Fundamental Data TypesDerived Data Types
The fundamental data types, also known as primitive data types, are basic data types in C LanguageDerived datatypes are composed of primitive data types
Fundamental data types are int, char, float, void, etc.Examples of Derived data types are arrays, structures, pointers, etc.
Variables with primitive data type store only one value/data.Derived data types like structure, arrays, etc., store multiple data (homogeneous/heterogeneous)
Ex: -int main(){int a = 5;char ch = ‘a’;}Ex: -int main(){int array1[6];  //array declaration}

39. What are postfix and prefix operators?

 Code exampleInitial value of aThe final value of bThe final value of a
Pre-increment/ prefix operatorb = ++a;233
Post-increment/ postfix operatorb = a++;223
Pre-decrement/ prefix operatorb = – – a;211
Post-decrement/postfix operator b = a – -;221

40. What are SQL joins? Which is your favorite join?

Joins in SQL combine data from two or more tables based on the common column between the two tables. There are different types of Join:

  • INNER JOIN: Returns records that have matching values in both tables
  • LEFT OUTER JOIN: Returns all records from the left table and the matched records from the right table
  • RIGHT OUTER JOIN: Returns all records from the right table and the matched records from the left table
  • FULL OUTER JOIN: Returns all records when there is a match in either the left or right table

Mention any one of the above joins, which is your favorite Join. The answer here is subjective to you.

41. Write a query to fetch only the first 3 records from the database.

The simplest query to fetch the top three rows of any table is as follows:

select * from (select * from student order by student_id) where rownum <=3;

42. What is the disadvantage of an indexed sequential file?

When it comes to file accessibility from Secondary storage devices, indexed sequential access is one of the ways to access the files, but there is a disadvantage to this method. In the Indexed sequential access mechanism, the data files are accessed with the help of index files, but these index files are accessed sequentially when multiple data are stored in a record. 

  • As the number of records increases, adding the key for newly added records in the index can completely reorganize all index files. 
  • Even frequent deletion of records can lead to inefficiency in the access mechanism of files.

43. Is it possible to overload a procedure in a package?

Yes, it is possible.

44. What is cloud computing? How is it useful today?

Cloud computing provides an environment to store, access, and work on resources remotely without storing them on a local computer or remote servers. The data/resources here are on the cloud, which refers to the available space among the multiple systems connected in a network (depending on the availability of space on each system in a network). There are different deployment models used in the cloud. It is helpful in many ways nowadays:

  1. We can install and run software without actually installing it on our system.
  2. We have access to a vast amount of space to store data, even though there is no space on the local machine or servers
  3. Servers, networks, storage, development tools, and even apps are enabled through the internet because of cloud computing
  4. Cloud platforms are elastic

45. Tell us about the different cloud computing service models.

There are the following types of cloud computing service models:-

  1. IaaS (Infrastructure as a Service) – Provides renting servers and data storage in the cloud rather than purchasing and maintaining its infrastructure.
  2. PaaS (Platform as a Service) – An accesses to a pre-defined environment for software development that can be used to build, test, and run applications.
  3. SaaS (Software as a Service) – A  way for organizations to access software applications.

46. Do you know about Big Data?

Yes, I know. Big Data is a huge collection of data, and it’s so prominent that traditional Database management tools won’t be sufficient to store, process, and access data. 

Ex:

  1. New York Stock Exchange
  2. Facebook users data

47. What is a foreign key?

A foreign key in a table is a unique combination of one or more than one attribute that uniquely identifies the records in the table. A foreign key is commonly used to link two tables together. A foreign key can be the primary key for a table but act as a foreign key for other tables.

48. What are access specifiers?

The access specifiers are the keywords used for functions, classes, interfaces, etc., to specify the information. Following are three access specifiers in C++.

Private

If data members and methods are declared private, they can be accessed only within the current Class.

A class cannot be defined as private.

Protected

If data members and methods are declared protected, they can be accessed within the current package and in the child class outside the package.

Public

If a class, data member, and methods are declared public, they can be accessed anywhere.

For data members, if Class and member both are public, then only that data member can be accessed from anywhere.

49. How can you initialize a global variable?

In C language, global variables are automatically initialized to 0 at the time of declaration. Global variables are declared before the main function, outside any other function. As it is a global variable, its scope is throughout the program and can be accessed by any function/code.

50. Can you write a program to find the sum of digits of a number?

import java.util.*;
public class Example
 {
    	public static void main(String[] args)
 {
        		int n1, sum;
        		System.out.print("Enter the number - ");
        		Scanner s1=new Scanner(System.in);
        		n1=s1.nextInt();
        		for(sum=0; n1!=0; n1=n1/10)
        		{
            			sum = sum + n1 % 10;
        		}
        		System.out.println("Sum of the digits of the number is - "+sum);
    	}
}

51. Given a linked list, remove the nth node from the end of the list and return its head.

import java.util.*;
class node{
    int data;
    node next;
}
class Example{
    static node create(int data){
        node tmp = new node();
        tmp.data = data;
        tmp.next = null;
        return tmp;
    }
    static node delete(node head, int n){
        node cur = head;
        while(n-- > 0){
            cur = cur.next;
            if(cur == null){
                cur = head;
                head = head.next;
                return head;
            }
        }
        node tmp = head;
        while(cur.next != null){
            tmp = tmp.next;
            cur = cur.next;
        }
        cur = tmp.next;
        tmp.next = tmp.next.next;
        return head;
    }
    public static void main(String[] args){
        node head = new node();
        head = create(2);
        head.next = create(4);
        head.next.next = create(6);
        head.next.next.next = create(8);
        head.next.next.next.next = create(9);
        head.next.next.next.next.next = create(3);
        System.out.print("Linked List  ");
        node tmp = head;
        while(tmp != null){
            System.out.print(tmp.data+" ");
            tmp = tmp.next;
        }
        head = delete(head, 4);
        System.out.print("\n"+"Linked List after deletion ");
        tmp = head;
        while(tmp!=null){
            System.out.print(tmp.data+" ");
            tmp = tmp.next;
        }
    }
}

52. Determine whether an integer is a palindrome. Do this without extra space.

import java.util.*;
public class Example {
    public static void main(String[] args) {
    int number, count =0;
    System.out.println("Enter the number to check for palindrome");
    Scanner s1 =new Scanner(System.in);
    number = s1.nextInt();
    if (number < 0)
        System.out.println("palindrome does not exists for negative no ");
    while (number != 0) {
        number /= 10;
        ++count;
    }
    int n =count/2;
    int divisor=1;
    for(int i=1;i<=n;i++) {
            divisor=divisor * 10;
    }
    int leftpart = number / divisor;
    int rightpart = number % divisor;
    System.out.println(leftpart);
    System.out.println(rightpart);
    int rev = 0;
    for(  ;rightpart != 0; rightpart=rightpart/10)
        {
            int remainder = rightpart % 10;
            rev = rev * 10 + remainder;
        }
        if (leftpart != rev)
            System.out.println("it is not a palindrome");
        else
            System.out.println("it is a palindrome");
        }
    }

With this, we are at the end of the HCL Interview Questions. While applying for a job at HCL, keep the following points in mind:

  • Read through the job description to understand the requirements of the job.
  • Optimize your resume to meet the requirements.
  • Practice your communication skills beforehand.
  • Be confident during the group interview round.

→ Explore this Curated Program for You ←

Avatar photo
Great Learning Editorial Team
The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.
Free Online Courses by Great Learning Academy
Scroll to Top