Add office photos
Engaged Employer

Cognizant

3.8
based on 47k Reviews
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by

100+ Interview Questions and Answers

Updated 10 Nov 2024
Popular Designations

Q1. A train travelling at a speed of 75 mph enters a tunnel 31/2 miles long. The train is 1/4 mile long. How long does it take for the train to pass through the tunnel from the moment the front enters to the moment...

read more
Ans.

Calculate the time taken by a train to pass through a tunnel given its speed, length, and the tunnel's length.

  • Convert the speed of the train from mph to miles per minute.

  • Calculate the time taken by the front of the train to enter the tunnel.

  • Calculate the time taken by the rear of the train to exit the tunnel.

  • Subtract the time taken by the front from the time taken by the rear to get the total time taken.

  • Add the units to the final answer.

View 4 more answers

Q2. What are different type of data structures and explain any 2 of them?

Ans.

Data structures are ways to organize and store data. Two examples are arrays and linked lists.

  • Arrays are a collection of elements of the same data type, stored in contiguous memory locations.

  • Linked lists are a collection of nodes, each containing data and a reference to the next node in the list.

View 3 more answers

Q3. What is a function and it's uses?

Ans.

A function is a block of code that performs a specific task and can be called multiple times.

  • Functions help in modularizing code and making it reusable.

  • Functions can take parameters and return values.

  • Functions can be defined in different ways such as function declaration, function expression, arrow function, etc.

  • Examples of functions include Math.max(), console.log(), and document.getElementById().

View 6 more answers

Q4. What are different types of algorthim methods in machine learning?

Ans.

There are various algorithm methods in machine learning, such as supervised learning, unsupervised learning, and reinforcement learning.

  • Supervised learning: Algorithms learn from labeled data to make predictions or classifications.

  • Unsupervised learning: Algorithms learn from unlabeled data to discover patterns or relationships.

  • Reinforcement learning: Algorithms learn through trial and error to maximize rewards.

  • Other methods include semi-supervised learning, transfer learning,...read more

View 4 more answers
Discover null interview dos and don'ts from real experiences

Q5. What is ment by the term void?

Ans.

Void refers to a state of emptiness or absence of something.

  • It can refer to a physical space that is empty or without matter.

  • It can also refer to a lack of something, such as a void in one's life or a void in a contract.

  • In programming, void is a data type used to indicate that a function does not return a value.

  • In law, a void contract is one that is not legally binding.

  • In physics, a vacuum is often referred to as a void.

View 3 more answers

Q6. What is a loop?

Ans.

A loop is a programming construct that repeats a set of instructions until a certain condition is met.

  • Loops are used to automate repetitive tasks in programming.

  • There are three types of loops: for, while, and do-while.

  • For example, a for loop can be used to iterate over an array and perform a certain action on each element.

  • A while loop can be used to repeat a set of instructions until a certain condition is no longer true.

  • A do-while loop is similar to a while loop, but it alwa...read more

View 6 more answers
Are these interview questions helpful?

Q7. Can you tell me about your Google Facilitator Ready program?

Ans.

Google Facilitator Ready program is a training program that equips individuals with skills to facilitate Google's workshops and events.

  • The program provides training on how to facilitate Google's workshops and events

  • Participants learn how to create engaging content and deliver it effectively

  • The program also covers how to manage logistics and handle participant questions

  • Upon completion, participants receive a certificate and are eligible to facilitate Google's events

  • Examples of...read more

View 2 more answers

Q8. What is ment by machine learning?

Ans.

Machine learning is a subset of artificial intelligence that enables machines to learn from data and improve their performance.

  • Machine learning involves training algorithms to make predictions or decisions based on data.

  • It uses statistical techniques to identify patterns in data and make predictions.

  • Examples include image recognition, speech recognition, and recommendation systems.

  • Machine learning can be supervised, unsupervised, or semi-supervised.

  • It is used in various indus...read more

View 3 more answers
Share interview questions and help millions of jobseekers 🌟

Q9. What is the difference between a primary key and a foreign key?

Ans.

Primary key uniquely identifies a record in a table, while foreign key refers to a field in another table.

  • Primary key is used to enforce data integrity and ensure uniqueness of records.

  • Foreign key is used to establish a relationship between two tables.

  • A table can have only one primary key, but multiple foreign keys.

  • Example: CustomerID in Orders table is a foreign key that references the Customer table's primary key.

  • Primary key is denoted by a key symbol, while foreign key is ...read more

View 2 more answers

Q10. Differentiate between supervised and unsupervised machine learning?

Ans.

Supervised learning uses labeled data to train models while unsupervised learning uses unlabeled data.

  • Supervised learning requires a target variable to be predicted while unsupervised learning does not.

  • Supervised learning algorithms include regression, classification, and decision trees while unsupervised learning algorithms include clustering and association.

  • Examples of supervised learning include predicting housing prices and classifying emails as spam or not, while example...read more

View 3 more answers

Q11. What are the data structures?

Ans.

Data structures are ways of organizing and storing data in a computer so that it can be accessed and used efficiently.

  • Data structures can be linear or non-linear

  • Examples of linear data structures include arrays, linked lists, and stacks

  • Examples of non-linear data structures include trees and graphs

  • Choosing the right data structure is important for efficient algorithm design

View 2 more answers

Q12. What are the latest technologies you have heard of?

Ans.

The latest technologies include AI, blockchain, 5G, quantum computing, and IoT.

  • AI - machine learning, natural language processing

  • Blockchain - decentralized ledgers, smart contracts

  • 5G - faster internet speeds, low latency

  • Quantum computing - exponential processing power

  • IoT - interconnected devices, data collection

Add your answer

Q13. What are the four Pillars of OOPS?

Ans.

The four pillars of OOPS are Abstraction, Encapsulation, Inheritance, and Polymorphism.

  • Abstraction: Hiding implementation details and showing only necessary information.

  • Encapsulation: Binding data and functions together and restricting access to them.

  • Inheritance: Creating new classes from existing ones, inheriting properties and methods.

  • Polymorphism: Ability of objects to take on multiple forms or behaviors.

View 1 answer

Q14. What is the difference between instance and local variable?

Ans.

Instance variables are declared in a class and can be accessed by any method in the class. Local variables are declared in a method and can only be accessed within that method.

  • Instance variables are declared at the class level, while local variables are declared within a method.

  • Instance variables can be accessed by any method in the class, while local variables can only be accessed within the method they are declared in.

  • Instance variables are initialized to default values, wh...read more

View 1 answer

Q15. Statements P: Some mobiles are cameras. Q: Some cameras are calculators. Conclusions I. All calculators are mobiles. II. All cameras are mobiles

Ans.

The conclusions cannot be determined from the given statements.

  • Statement P and Q do not have a direct relationship.

  • There is no information given about the relationship between calculators and cameras.

  • Therefore, neither conclusion can be drawn.

Add your answer

Q16. In which programming language you are comfortable?

Ans.

I am comfortable in multiple programming languages including Python, Java, and C++.

  • Python

  • Java

  • C++

View 1 answer

Q17. If suddenly the python language was made obsolete and Java was the main programing language suddenly, how would you cope up with this change?

Ans.

I would adapt by learning Java and leveraging my programming skills to transition smoothly.

  • I would start by taking online courses or tutorials to quickly learn Java syntax and best practices.

  • I would also seek guidance from colleagues or mentors who are experienced in Java programming.

  • I would practice coding in Java by working on small projects or contributing to open source projects.

  • I would stay updated on Java trends and advancements to ensure I am proficient in the language...read more

View 1 answer

Q18. What are the different data types in python?

Ans.

Python has several built-in data types including numeric, sequence, and mapping types.

  • Numeric types include integers, floats, and complex numbers.

  • Sequence types include lists, tuples, and strings.

  • Mapping types include dictionaries.

  • Boolean type is also available.

  • Type() function can be used to determine the data type of a variable.

View 1 answer

Q19. what is the difference between while and do while?

Ans.

while loop checks condition before executing, do while loop executes at least once before checking condition.

  • while loop is entry controlled loop, do while loop is exit controlled loop

  • while loop may not execute at all if condition is false initially, do while loop executes at least once

  • while loop syntax: while(condition){ //code to execute }

  • do while loop syntax: do{ //code to execute }while(condition);

Add your answer

Q20. What are the different types of Joins in SQL?

Ans.

There are four types of Joins in SQL: Inner Join, Left Join, Right Join, and Full Outer Join.

  • Inner Join returns only the matching rows from both tables.

  • Left Join returns all the rows from the left table and matching rows from the right table.

  • Right Join returns all the rows from the right table and matching rows from the left table.

  • Full Outer Join returns all the rows from both tables, with NULL values in the columns where there is no match.

  • Examples: SELECT * FROM table1 INNER...read more

Add your answer

Q21. Statements P: Some bags are hot. Q: All hots are cakes. Conclusions I. All cakes are bags. II. Some bags are cakes.

Ans.

Conclusion II follows from the given statements.

  • Statement P and Q do not provide enough information to conclude that all cakes are bags.

  • However, it can be concluded that some bags are cakes as some bags are hot and all hots are cakes.

  • Therefore, Conclusion II is true while Conclusion I is false.

Add your answer

Q22. What is the difference between C and C++?

Ans.

C++ is an extension of C with object-oriented programming features.

  • C++ supports classes and objects while C does not.

  • C++ has better support for polymorphism and inheritance.

  • C++ has a standard template library (STL) for data structures and algorithms.

  • C++ allows function overloading and default arguments.

  • C++ has exception handling for error management.

  • C++ is more complex and has a steeper learning curve than C.

Add your answer

Q23. Which is the most comfortable programming language for you?

Ans.

Python is the most comfortable programming language for me.

  • Python has a simple and easy-to-learn syntax.

  • It has a vast collection of libraries and frameworks.

  • Python is versatile and can be used for various applications such as web development, data analysis, and machine learning.

  • Python has a large community that provides support and resources.

  • Examples: Flask, Django, NumPy, Pandas, TensorFlow.

Add your answer

Q24. What do you know about Cognizant?

Ans.

Cognizant is a multinational technology company providing digital, technology, consulting, and operations services.

  • Founded in 1994 and headquartered in Teaneck, New Jersey

  • Has a global presence with operations in over 40 countries

  • Offers services in areas such as artificial intelligence, cloud computing, and cybersecurity

  • Works with clients across various industries including healthcare, finance, and retail

  • Has over 300,000 employees worldwide

Add your answer

Q25. Simple SQL query to find duplicate items in a database.

Ans.

SQL query to find duplicate items in a database.

  • Use GROUP BY clause to group the items by their values

  • Use HAVING clause to filter out groups with count greater than 1

  • Select the columns you want to display in the result

Add your answer

Q26. Write a program for reverse string?

Ans.

A program to reverse a given string.

  • Create an empty string to store the reversed string

  • Loop through the original string from the end to the beginning

  • Add each character to the new string

  • Return the new string

View 2 more answers

Q27. what is c,c++,difference between c and c++

Ans.

C and C++ are programming languages. C++ is an extension of C with additional features.

  • C is a procedural language while C++ is an object-oriented language.

  • C++ supports features like classes, inheritance, and polymorphism which are not present in C.

  • C++ also has better support for templates and exception handling compared to C.

  • C++ code can also be written in a more modular and reusable way compared to C.

  • C++ is often used for developing complex software systems like operating sy...read more

Add your answer

Q28. Write a code to print first 10 element of Fibonacci series.

Ans.

Code to print first 10 elements of Fibonacci series.

  • Declare variables for first two numbers of the series

  • Use a loop to generate the next numbers in the series

  • Print the first 10 numbers of the series

View 1 answer

Q29. Why does Java have no pointers?

Ans.

Java has no pointers for safety reasons and to simplify memory management.

  • Java uses references instead of pointers to avoid security vulnerabilities.

  • Pointers can cause memory leaks and dangling references, which Java avoids.

  • Java's garbage collector automatically manages memory, making pointers unnecessary.

  • Example: Java's NullPointerException is a result of using a null reference, not a pointer.

  • Example: C++ allows pointer arithmetic, which can lead to buffer overflows and othe...read more

Add your answer

Q30. Is python is case sensitive?what are decorators in python?

Ans.

Yes, Python is case sensitive. Decorators are functions that modify the behavior of other functions.

  • Python is case sensitive, meaning that 'hello' and 'Hello' are two different variables

  • Decorators are functions that take another function as input and extend its functionality

  • They are denoted by the '@' symbol and placed above the function definition

  • Example: @decorator_function def my_function(): # code here

  • Common decorators include @staticmethod, @classmethod, and @property

Add your answer

Q31. Code for recursion function,what is the samllest product of 10 whole number

Ans.

Recursion function code and finding smallest product of 10 whole numbers.

  • Recursion function code: function recursion(num) { if(num === 0) { return 1; } else { return num * recursion(num-1); } }

  • To find smallest product of 10 whole numbers, we can multiply the smallest 5 negative numbers with the smallest 5 positive numbers.

  • Example: [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] => (-5) * (-4) * (-3) * (-2) * (-1) * 1 * 2 * 3 * 4 * 5 = -1200

Add your answer

Q32. Why java is platform independent?

Ans.

Java is platform independent because it uses the concept of bytecode and virtual machine.

  • Java programs are compiled into bytecode, which is a platform-independent representation of the code.

  • The bytecode is then executed by the Java Virtual Machine (JVM), which is specific to each platform.

  • The JVM interprets the bytecode and translates it into machine code that can be understood by the underlying operating system.

  • This allows Java programs to run on any platform that has a comp...read more

View 1 answer

Q33. write a coding for given year is leap or not

Ans.

Coding to check if a given year is leap or not

  • A year is a leap year if it is divisible by 4 but not by 100, or if it is divisible by 400

  • Use modulo operator to check if the year is divisible by 4, 100, and 400

  • Return true if the year is divisible by 4 and not by 100, or if it is divisible by 400. Else, return false

View 1 answer

Q34. What is prefix notation? Write one example.

Ans.

Prefix notation is a way of writing mathematical expressions where the operator comes before the operands.

  • Also known as Polish notation

  • Example: + 2 3 is equivalent to 2 + 3

  • Useful in computer science for evaluating expressions

  • Requires less parentheses than infix notation

Add your answer

Q35. write a code to connect database in python

Ans.

Code to connect database in Python

  • Import the required module (e.g. pymysql, sqlite3)

  • Establish a connection to the database using connect() method

  • Create a cursor object using cursor() method

  • Execute SQL queries using execute() method

  • Commit changes using commit() method

  • Close the cursor and connection using close() method

Add your answer

Q36. How to create an empty class?

Ans.

An empty class can be created by simply declaring a class with no properties or methods.

  • Declare a class with no properties or methods

  • Example: class EmptyClass {}

  • The class can be used as a placeholder for future implementation

View 1 answer

Q37. What is constructor overloading?

Ans.

Constructor overloading is the ability to have multiple constructors with different parameters in a class.

  • Constructor overloading allows creating objects with different initializations.

  • It helps in providing flexibility and convenience to the users of the class.

  • Constructors can be overloaded by changing the number, type, or order of parameters.

  • Example: class Person { Person() {} Person(String name) {} }

View 1 answer

Q38. What is HTML?

Ans.

HTML stands for Hypertext Markup Language. It is the standard markup language used to create web pages.

  • HTML is used to structure content on the web

  • It uses tags to define elements such as headings, paragraphs, and links

  • It can also include multimedia elements such as images and videos

  • HTML is the backbone of the web and is essential for creating websites and web applications

View 1 answer

Q39. WAP to get 3rd largest odd number in an array?

Ans.

Find the 3rd largest odd number in an array of strings.

  • Convert the array of strings to an array of integers.

  • Filter out the odd numbers from the array.

  • Sort the odd numbers in descending order.

  • Return the 3rd element from the sorted array.

Add your answer

Q40. Do you have any backlogs?

Ans.

No, I do not have any backlogs.

  • I have successfully completed all my courses and exams.

  • I have maintained a good academic record throughout.

  • I have never had to repeat a course or exam.

  • I have always been diligent in my studies and time management.

Add your answer

Q41. what are the features of oops?

Ans.

Object-oriented programming features include encapsulation, inheritance, polymorphism, and abstraction.

  • Encapsulation: bundling of data and methods that manipulate the data

  • Inheritance: creating new classes from existing ones

  • Polymorphism: ability of objects to take on multiple forms

  • Abstraction: hiding implementation details from users

Add your answer

Q42. What is cloud computing?

Ans.

Cloud computing is the delivery of computing services over the internet.

  • Cloud computing allows users to access data and applications from anywhere with an internet connection.

  • It offers scalability, flexibility, and cost-effectiveness compared to traditional on-premises computing.

  • Examples include Amazon Web Services, Microsoft Azure, and Google Cloud Platform.

Add your answer

Q43. What are OOPS concepts?

Ans.

OOPS concepts are the fundamental principles of Object-Oriented Programming that help in designing and implementing software systems.

  • Encapsulation: Bundling data and methods together in a class.

  • Inheritance: Creating new classes from existing ones, inheriting their properties and behaviors.

  • Polymorphism: Objects of different classes can be treated as objects of a common superclass.

  • Abstraction: Hiding complex implementation details and providing simplified interfaces.

  • Encapsulati...read more

View 1 answer

Q44. What's the difference between list and tuple?

Ans.

List is mutable while tuple is immutable.

  • Lists can be modified while tuples cannot

  • Lists use square brackets [] while tuples use parentheses ()

  • Lists are used for collections of data that can be changed while tuples are used for fixed collections of data

  • Lists are slower than tuples

  • Example: list = [1, 2, 3], tuple = (1, 2, 3)

Add your answer

Q45. Explain polymorphism, inheritance and OOPS.

Ans.

Polymorphism, inheritance and OOPS are concepts in object-oriented programming.

  • Polymorphism allows objects of different classes to be treated as if they are of the same class.

  • Inheritance allows a class to inherit properties and methods from another class.

  • OOPS is a programming paradigm that uses objects to represent real-world entities and their interactions.

  • Example of polymorphism: A shape class with different subclasses like circle, square, and triangle.

  • Example of inheritanc...read more

Add your answer

Q46. Which programming language do you know?

Ans.

I know multiple programming languages including Java, Python, and C++.

  • Proficient in Java, Python, and C++

  • Familiar with JavaScript, HTML, and CSS

  • Experience with SQL and NoSQL databases

Add your answer

Q47. Difference between list and tuple?

Ans.

List is mutable and tuple is immutable in Python.

  • Lists can be modified while tuples cannot be modified once created.

  • Lists are defined using square brackets while tuples are defined using parentheses.

  • Lists are used for collections of homogeneous items while tuples are used for heterogeneous items.

  • Lists are slower than tuples in terms of performance.

  • Example of list: my_list = [1, 2, 3]

  • Example of tuple: my_tuple = (1, 'hello', 3.14)

Add your answer

Q48. What is JVM?

Ans.

JVM stands for Java Virtual Machine. It is an abstract machine that enables a computer to run Java programs.

  • JVM is responsible for interpreting the compiled Java code and executing it on the computer.

  • It provides a platform-independent environment for Java programs to run on different operating systems.

  • JVM has various components such as Class Loader, Bytecode Verifier, Just-In-Time Compiler, and Garbage Collector.

  • Examples of JVM-based languages include Java, Kotlin, and Scala.

Add your answer

Q49. what error do you get if you break immutablity?

Ans.

Attempting to modify an immutable object will result in a compilation error or runtime exception.

  • Attempting to modify a string literal will result in a compilation error.

  • Trying to modify elements of an immutable list like ImmutableList in Java will throw an UnsupportedOperationException.

  • Modifying a frozen set in Python will raise a TypeError.

Add your answer

Q50. write a program to get the maximum value from an array.

Ans.

Program to find the maximum value from an array of strings.

  • Convert the array elements to integers using parseInt()

  • Use Math.max() to find the maximum value

  • Handle empty arrays

Add your answer

Q51. State the differences between C and C++.

Ans.

C++ is an extension of C with object-oriented programming features.

  • C++ supports classes and objects while C does not.

  • C++ has constructors and destructors while C does not.

  • C++ supports function overloading while C does not.

  • C++ has namespaces while C does not.

  • C++ supports exception handling while C does not.

Add your answer

Q52. Difference Between Abstraction and Encapsulation?

Ans.

Abstraction is about hiding complexity while encapsulation is about hiding implementation details.

  • Abstraction is a way of reducing complexity by hiding unnecessary details.

  • Encapsulation is a way of protecting data by hiding implementation details.

  • Abstraction is achieved through interfaces and abstract classes.

  • Encapsulation is achieved through access modifiers like private, public, and protected.

  • Abstraction is like a car dashboard where you only see the necessary information.

  • E...read more

Add your answer

Q53. What is AI,ML and cloud computing

Ans.

AI stands for Artificial Intelligence, ML stands for Machine Learning, and Cloud Computing is the delivery of computing services over the internet.

  • AI refers to the simulation of human intelligence in machines that are programmed to think and learn like humans.

  • ML is a subset of AI that involves training algorithms to make predictions or decisions based on data.

  • Cloud Computing allows users to access computing resources, such as servers, storage, and databases, over the internet...read more

Add your answer

Q54. Main Differences Between C++ and Java

Ans.

C++ and Java are both object-oriented programming languages, but differ in syntax, memory management, and platform compatibility.

  • C++ supports multiple inheritance, while Java only supports single inheritance.

  • C++ allows direct memory manipulation, while Java has a garbage collector for automatic memory management.

  • C++ is closer to the hardware and provides more control, while Java is platform-independent and provides portability.

  • C++ has pointers, while Java uses references.

  • C++ ...read more

View 1 answer

Q55. Define memory management in Python

Ans.

Memory management in Python involves allocation and deallocation of memory for objects.

  • Python uses automatic memory management through garbage collection.

  • Memory is allocated dynamically as objects are created.

  • Unused memory is automatically deallocated through reference counting or garbage collection.

  • Python provides tools like sys.getsizeof() and tracemalloc to manage memory usage.

  • Memory leaks can occur if objects are not properly deallocated.

Add your answer

Q56. How many layers in OSI model, Name them.

Ans.

The OSI model has 7 layers that define how data is transmitted over a network.

  • The layers are: Physical, Data Link, Network, Transport, Session, Presentation, and Application.

  • Each layer has a specific function and communicates with the layers above and below it.

  • For example, the Physical layer deals with the physical transmission of data, while the Application layer deals with user interfaces and applications.

  • The OSI model is a conceptual model and is used to help understand ho...read more

Add your answer

Q57. What is a database?

Ans.

A database is a structured collection of data that is stored and organized for easy retrieval and manipulation.

  • A database is used to store and manage large amounts of data.

  • It allows for easy retrieval and manipulation of data.

  • Data is organized into tables, with each table containing related information.

  • Examples of databases include MySQL, Oracle, and MongoDB.

Add your answer

Q58. Write programs to print 1 to 20 prime numbers

Ans.

Program to print the first 20 prime numbers.

  • Start a loop from 2 to a large number

  • Check if each number is prime by dividing it with numbers from 2 to its square root

  • If a number is prime, add it to a list

  • Stop the loop when the list has 20 prime numbers

  • Print the list of prime numbers

Add your answer

Q59. Write any program to show recursion.

Ans.

Recursion is a process in which a function calls itself as a subroutine.

  • Recursion can be used to solve problems that can be broken down into smaller sub-problems of the same type.

  • It is important to have a base case to prevent infinite recursion.

  • Examples of recursive functions include factorial, Fibonacci sequence, and binary search.

  • Recursion can also be used to traverse data structures such as trees and graphs.

Add your answer

Q60. What is DBMS?

Ans.

DBMS stands for Database Management System. It is a software that manages and organizes data in a structured manner.

  • DBMS is used to create, retrieve, update, and delete data in a database.

  • It provides a way to store and organize large amounts of data efficiently.

  • DBMS ensures data integrity, security, and concurrency control.

  • Examples of popular DBMS include MySQL, Oracle, SQL Server, and PostgreSQL.

View 1 answer

Q61. What is pointer?

Ans.

A pointer is a variable that stores the memory address of another variable.

  • Pointers allow for dynamic memory allocation and manipulation.

  • They are commonly used in programming languages like C and C++.

  • Example: int *ptr; ptr = # *ptr = 10; // num now has a value of 10

Add your answer

Q62. What are loops?

Ans.

Loops are programming structures that allow a set of instructions to be repeated multiple times.

  • Loops are used to iterate over arrays or perform a set of instructions a certain number of times.

  • There are three types of loops in most programming languages: for, while, and do-while.

  • Example: for (var i = 0; i < 10; i++) { console.log(i); }

  • Example: while (condition) { // code block }

  • Example: do { // code block } while (condition);

Add your answer

Q63. Types of inheritance?

Ans.

Types of inheritance include single, multiple, multilevel, hierarchical, hybrid, and multipath inheritance.

  • Single inheritance: a class inherits from a single base class.

  • Multiple inheritance: a class inherits from multiple base classes.

  • Multilevel inheritance: a class inherits from a derived class, which in turn inherits from another class.

  • Hierarchical inheritance: multiple classes inherit from a single base class.

  • Hybrid inheritance: a combination of multiple and multilevel inh...read more

View 1 answer

Q64. write a code that returns null

Ans.

Code snippet to return null

  • In Java: return null;

  • In Python: return None

  • In C#: return null;

  • In JavaScript: return null;

Add your answer

Q65. What is pointers?

Ans.

Pointers are variables that store memory addresses. They allow direct manipulation of memory and facilitate efficient memory management.

  • Pointers store memory addresses

  • They allow direct manipulation of memory

  • They facilitate efficient memory management

View 1 answer

Q66. What is import function used for.

Ans.

The import function is used to bring external data or modules into a program.

  • It allows for the use of external libraries or modules in a program

  • It can be used to import data from other files or sources

  • It is commonly used in programming languages such as Python and JavaScript

  • Example: import pandas as pd (Python library for data analysis)

Add your answer

Q67. What is product of first 5 prime number

Ans.

The product of the first 5 prime numbers is 2 x 3 x 5 x 7 x 11 = 2310.

  • The first 5 prime numbers are 2, 3, 5, 7, and 11.

  • To find the product, multiply these numbers together.

  • The product of the first 5 prime numbers is 2 x 3 x 5 x 7 x 11 = 2310.

Add your answer

Q68. Is python interpreted language?

Ans.

Yes, Python is an interpreted language.

  • Python code is executed line by line without compilation

  • Python interpreter converts code into bytecode and executes it

  • Python interpreter is available for multiple platforms

  • Python can also be compiled into executable code using tools like PyInstaller

Add your answer

Q69. Difference between c, c++ and java

Ans.

C is a procedural language, C++ is an object-oriented language, and Java is a class-based object-oriented language.

  • C is a low-level language used for system programming and embedded systems.

  • C++ is an extension of C with added features like classes, inheritance, and polymorphism.

  • Java is platform-independent and has automatic memory management through garbage collection.

  • Java programs run on a virtual machine, while C and C++ programs are compiled into machine code.

  • C++ is often ...read more

Add your answer

Q70. difference between array and list.

Ans.

Arrays are fixed in size and hold elements of the same data type, while lists are dynamic and can hold elements of different data types.

  • Arrays are declared with a fixed size, while lists can grow or shrink dynamically.

  • Arrays can only hold elements of the same data type, while lists can hold elements of different data types.

  • Arrays are accessed using an index, while lists are accessed using an iterator.

  • Examples: int[] arr = new int[5]; List list = new ArrayList<>();

Add your answer

Q71. What is c programming,arrays,datatypes

Ans.

C programming is a powerful language used for system programming, arrays are collections of elements, and datatypes define the type of data.

  • C programming is a versatile language used for system programming and developing software applications.

  • Arrays in C are collections of elements of the same data type, accessed using index numbers.

  • Datatypes in C define the type of data that a variable can hold, such as int, float, char, etc.

Add your answer

Q72. What is JVM What are Oops Concept

Ans.

JVM stands for Java Virtual Machine. Oops concepts are the fundamental concepts of object-oriented programming in Java.

  • JVM is an abstract machine that provides a runtime environment for Java programs.

  • Oops concepts include encapsulation, inheritance, polymorphism, and abstraction.

  • Encapsulation is the process of hiding implementation details from the user.

  • Inheritance allows a class to inherit properties and methods from another class.

  • Polymorphism allows objects to take on multi...read more

Add your answer

Q73. What are the directories of python

Ans.

Python has several directories including site-packages, dist-packages, and user site-packages.

  • site-packages directory contains third-party packages installed globally

  • dist-packages directory contains packages installed by the distribution's package manager

  • user site-packages directory contains packages installed by the user

  • sys.path is a list of directories searched for modules

  • PYTHONPATH environment variable can be used to add additional directories to sys.path

Add your answer

Q74. Write program on 1 01 101 1010 10101

Ans.

The program prints a pattern of alternating 1s and 0s in a specific sequence.

  • Use a loop to iterate through the given sequence of numbers

  • Inside the loop, check the length of each number and print the corresponding pattern of 1s and 0s

  • Repeat the pattern until all numbers are processed

View 1 answer

Q75. What is infix notation?

Ans.

Infix notation is a mathematical notation where operators are placed between operands.

  • Infix notation is the most commonly used notation in mathematics.

  • In infix notation, operators are placed between operands.

  • Infix notation is used in programming languages like C, Java, and Python.

  • Examples of infix notation include 2 + 3, 4 * 5, and 6 / 2.

Add your answer

Q76. To find largest word in a string and print it

Ans.

Use a loop to iterate through each word in the string and compare their lengths to find the largest word.

  • Split the string into an array of words using a space as the delimiter

  • Initialize a variable to store the largest word found so far

  • Iterate through the array of words and compare the length of each word to the length of the current largest word

  • Update the largest word if a longer word is found

  • Print the largest word after iterating through all words

Add your answer

Q77. What are the types of loops

Ans.

Types of loops include for loop, while loop, and do-while loop.

  • For loop: Executes a block of code a specified number of times.

  • While loop: Executes a block of code as long as a specified condition is true.

  • Do-while loop: Similar to while loop but always executes the block of code at least once.

Add your answer

Q78. Explain Pass, continue and break ?

Ans.

Pass, continue and break are control statements used in loops and conditional statements.

  • Pass statement is used to do nothing in a loop or conditional statement.

  • Continue statement is used to skip the current iteration of a loop and move to the next iteration.

  • Break statement is used to exit out of a loop or conditional statement.

Add your answer

Q79. What is TCP/IP model?

Ans.

TCP/IP model is a networking protocol that defines how data is transmitted over the internet.

  • TCP/IP model has four layers: application, transport, internet, and network access.

  • Each layer has its own set of protocols and functions.

  • TCP/IP model is used for communication between devices on the internet.

  • Examples of protocols used in TCP/IP model include HTTP, FTP, TCP, and IP.

Add your answer

Q80. Example function overloading and overriding

Ans.

Function overloading is having multiple functions with the same name but different parameters, while function overriding is redefining a function in a subclass.

  • Function overloading: Same function name but different parameters (e.g. sum(int a, int b) and sum(double a, double b)

  • Function overriding: Redefining a function in a subclass with the same name and parameters as in the superclass

  • Overloading is resolved at compile time, while overriding is resolved at runtime

Add your answer

Q81. What is operator overloading?

Ans.

Operator overloading is the ability to redefine operators for custom classes.

  • Allows operators to be used with custom classes

  • Enables the use of familiar operators with custom classes

  • Can improve code readability and reduce complexity

  • Example: overloading the + operator for a custom Vector class to add two vectors

Add your answer

Q82. What is slicing in python?

Ans.

Slicing is a way to extract a portion of a sequence (string, list, tuple) in Python.

  • Syntax: sequence[start:stop:step]

  • start is the index where the slice starts (inclusive)

  • stop is the index where the slice ends (exclusive)

  • step is the interval between each index in the slice

  • Examples: 'hello'[1:4] returns 'ell', [1,2,3,4,5][::2] returns [1,3,5]

Add your answer

Q83. Explain Inheritance

Ans.

Inheritance is a concept in object-oriented programming where a class inherits properties and behaviors from another class.

  • Inheritance allows for code reuse and promotes the concept of hierarchy.

  • The class that is being inherited from is called the superclass or base class.

  • The class that inherits from the superclass is called the subclass or derived class.

  • The subclass can access the public and protected members of the superclass.

  • Inheritance can be single, where a subclass inhe...read more

View 1 answer

Q84. program to print odd prime number?

Ans.

A program to print odd prime numbers.

  • Start with a loop to iterate through all odd numbers

  • Check if the number is prime using a function

  • If the number is prime, print it

Add your answer

Q85. Table vs views in sql

Ans.

Tables store data in a structured format, while views are virtual tables that display data from one or more tables.

  • Tables store actual data, while views store queries that display data

  • Tables can be modified directly, while views are read-only

  • Views can simplify complex queries by combining data from multiple tables

  • Tables are physical structures, while views are logical structures

Add your answer

Q86. Difference between array and linkedlist?

Ans.

Arrays are contiguous blocks of memory while linked lists are nodes linked by pointers.

  • Arrays have fixed size while linked lists can grow dynamically.

  • Insertion and deletion are faster in linked lists than in arrays.

  • Arrays have direct access to elements while linked lists need to traverse from the beginning.

  • Arrays are better for random access while linked lists are better for sequential access.

  • Examples of arrays: int[] arr = {1, 2, 3}; string[] names = {"John", "Mary", "Bob"};...read more

Add your answer

Q87. What is data structure

Ans.

Data structure is a way of organizing and storing data in a computer so that it can be accessed and manipulated efficiently.

  • Data structures define the way data is stored, accessed, and manipulated in a computer program.

  • Examples of data structures include arrays, linked lists, stacks, queues, trees, and graphs.

  • Choosing the right data structure is crucial for optimizing the performance of algorithms and programs.

Add your answer

Q88. Tell more about python

Ans.

Python is a high-level, interpreted programming language known for its simplicity and ease of use.

  • Python is used for web development, data analysis, artificial intelligence, and more.

  • It has a large standard library and supports multiple programming paradigms.

  • Python code is easy to read and write, making it a popular choice for beginners.

  • Python is dynamically typed, meaning variables can change type during runtime.

  • Popular frameworks for web development in Python include Django...read more

Add your answer

Q89. What is dbms and sql

Ans.

DBMS stands for Database Management System and SQL stands for Structured Query Language.

  • DBMS is a software system that allows users to define, create, maintain and control access to databases.

  • SQL is a programming language used to manage and manipulate data stored in relational databases.

  • DBMS and SQL are often used together to manage and query data in databases.

  • Examples of popular DBMS include Oracle, MySQL, and Microsoft SQL Server.

  • Examples of SQL commands include SELECT, INS...read more

Add your answer

Q90. What is recursion?

Ans.

Recursion is a process in which a function calls itself as a subroutine.

  • Recursion is used to solve problems that can be broken down into smaller, simpler problems.

  • It involves a base case and a recursive case.

  • Examples include factorial, Fibonacci sequence, and binary search.

  • Recursion can be memory-intensive and may cause stack overflow if not implemented properly.

Add your answer

Q91. Explain inheritance with example

Ans.

Inheritance is a concept in object-oriented programming where a class can inherit attributes and methods from another class.

  • Allows a class to inherit attributes and methods from another class

  • Promotes code reusability and reduces redundancy

  • Derived class can add its own attributes and methods or override existing ones

  • Example: Parent class 'Animal' with attributes 'name' and method 'eat', Child class 'Dog' inherits 'Animal' and adds attribute 'breed' and method 'bark'

Add your answer

Q92. What is Database

Ans.

A database is a structured collection of data that is organized in a way that allows for easy access, management, and retrieval.

  • A database typically consists of tables, which contain rows and columns of data.

  • It allows for efficient storage and retrieval of large amounts of data.

  • Examples of databases include MySQL, Oracle, and MongoDB.

Add your answer

Q93. What is headerfile

Ans.

A header file is a file containing declarations of functions, variables, and constants that can be included in a program.

  • Header files typically have a .h extension and are included in source code using #include directive.

  • They help in organizing code, promoting reusability, and reducing compilation time.

  • Examples of header files include for standard input/output functions and for mathematical functions.

Add your answer

Q94. What is inheritance

Ans.

Inheritance is the process by which genetic information is passed down from parents to their offspring.

  • Inheritance determines traits such as eye color, hair color, and height.

  • It occurs through the transmission of DNA from parent to child.

  • Inherited traits can be dominant or recessive, and can be influenced by multiple genes.

  • Mutations in genes can also affect inheritance patterns.

  • Inheritance can be studied through pedigree analysis.

Add your answer

Q95. difference between lists and array

Ans.

Arrays are fixed in size and hold elements of the same data type, while lists are dynamic and can hold elements of different data types.

  • Arrays are declared with a fixed size, while lists can grow or shrink dynamically.

  • Arrays can only hold elements of the same data type, while lists can hold elements of different data types.

  • Arrays are accessed using an index, while lists are accessed using an iterator.

  • Example: int[] arr = new int[5]; List list = new ArrayList<>();

Add your answer

Q96. What is polymorphism

Ans.

Polymorphism is the ability of an object to take on many forms.

  • Polymorphism allows objects to be treated as if they are of different types.

  • It is achieved through method overloading and method overriding.

  • Example: A shape class can have different subclasses like circle, square, etc. and each subclass can have its own implementation of the draw method.

  • Polymorphism makes code more flexible and reusable.

Add your answer

Q97. Introducte yourself

Ans.

I am a software engineer with 5 years of experience in developing web applications.

  • I have a Bachelor's degree in Computer Science.

  • I am proficient in programming languages such as Java, Python, and JavaScript.

  • I have experience working with frameworks such as Spring, Django, and React.

  • I am a quick learner and enjoy working in a team environment.

  • In my free time, I enjoy reading books on technology and playing video games.

Add your answer

Q98. What IDE do you use.

Ans.

I use Visual Studio Code as my primary IDE.

  • VS Code has a user-friendly interface and supports a wide range of programming languages.

  • It has a built-in terminal and debugger for easy debugging.

  • VS Code also has a vast collection of extensions that enhance its functionality.

  • It is free and open-source software.

  • Some of the popular extensions include GitLens, Prettier, and Live Server.

Add your answer

Q99. write a code for palindrome

Ans.

Code to check if a string is a palindrome or not

  • Create a function that takes a string as input

  • Reverse the string and compare it with the original string

  • If they are the same, return true; otherwise, return false

Add your answer

Q100. define function?

Ans.

A function is a block of code that performs a specific task and can be called multiple times throughout a program.

  • Functions can take in parameters and return values

  • Functions can be defined using function declarations or function expressions

  • Functions can be assigned to variables and passed as arguments to other functions

Add your answer
1
2

More about working at Cognizant

Top Rated Mega Company - 2024
Top Rated IT/ITES Company - 2024
HQ - Teaneck. New Jersey., United States (USA)
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at null

based on 25 interviews in the last 1 year
3 Interview rounds
Aptitude Test Round
Coding Test Round
Technical Round
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter