String is the primary and probably most common thing you come across on any programming language and so is with any programming interview. There is almost always a question on String whether its related to length or replace but I have always find one or two String programming questions on interviews.
1) Write code to check a String is palindrome or not?
Palindrome are those String whose reverse is equal to original.This can be done by following technique demonstrated in How to reverse String in Java without using API
2) Write a method which will remove any given character from a String?
3) Print all permutation of String both iterative and Recursive way?
4) Write a function to find out longest palindrome in a given string?

Some more String related Questions which mostly appear in Java programming interviews:
Difference between String and StringBuffer in Java
Why String is final in Java
How to Split String in java
Why Char array is preferred over String for storing password?

Programming questions on Array
programming questions asked in interview, programming interview questions and answersArray is one of the topics where most of programming questions is asked. There are many and many programming questions on Array and here I have included only some of them which is not very difficult to solve but some of array programming question can be extremely challenging, so well prepare this topic.

5) In an array 1-100 numbers are stored, one number is missing how do you find it?
6) In an array 1-100 exactly one number is duplicate how do you find it?
This article contains a trick to find duplicates in Array using Java programming language
7) In an array 1-100 many numbers are duplicates, how do you find it?
trick in this programming questions is by using hashmap or hashtable , we can store number as key and its occurrence as value, if number is already present in hashtable then increment its value or insert value as 1 and later on print all those numbers whose values are more than one.



8)Given two arrays, 1,2,3,4,5 and 2,3,1,0,5 find which number is not present in the second array.
Here is a quick tip to solve this programming question:  put the elements of the second array in the Hashtable and for every element of the first array, check whether it’s present in the hash or not, O/P all those elements from the first array that are not present in the hash table

9) How do you find second highest number in an integer array?


LinkedList Programming Interview Questions
10) How do you find middle element of a linked list in single pass?
To answer this programming question I would say you start with simple solution on which you traverse the LinkedList until you find the tail of linked list where it points to null to find the length of linked list  and then reiterating till middle. After this answer interviewer will ask you find the middle element in single pass and there you can explain that by doing space-time tradeoff you can use two pointers one incrementing one step at a time and other incrementing two step a time, so when first pointer reaches end of linked second pointer will point to the middle element.

11) How do you find 3rd element from last in single pass?
This programming question is similar to above and can be solved by using 2 pointers, start second pointer when first pointer reaches third place.
12) How do you find if there is any loop in singly linked list? How do you find the start of the loop?
This programming question can also be solved using 2 pointers and if you increase one pointer one step at a time and other as two steps at a time they will meet in some point if there is a loop.
13) How do you reverse a singly linked list?


Binary Tree Programming Interview Questions
Binary tree or simply tree is one of favorite topic for most of interviewer and pose real challenge if you struggle with recursion. Programming questions on tree can become increasingly difficult when you think iterative but sometime can be very easy if you come with recursive solution.
14) How do you find depth of binary tree?
15) Write code to print InOrder traversal of a tree?
16) Print out all leaf node of a binary tree?


Programming questions on searching and sorting
I have only included two programming questions related to searching and sorting but there are more can be finding on google. Purpose of these programming questions is to see whether programmer is familiar with essential search and sort mechanism or not.
17) Write a program to sort numbers using quick sort?
18) Write a program to implement binary search algorithm
19) How do you sort Java object using Comparator?
This is another Java specific programming questions and you can check how to sort Object using Comparator and Comparable for answer.


Programming questions on numbers
Most of the programming questions are based on numbers and these are the ones which most of us did on college level and mind you they still has value I have seen programmers with experience of 3 years struggle with these programming questions and doesn’t solve it some time and take a lot of time which simply shows that they are not in programming in there day to day work.
19) Write code to check whether a no is power of two or not?
20) Write a program to check whether a no is palindrome or not?
check out this post which shows how to reverse number in Java and can be used to find if its palindrome or not.
21) Write code to check whether a no is Armstrong no or not
Here is a Java program to find Armstrong number, you can use same logic to write code in any other programming language like C and C++.
22) Write a program to find all prime number up to a given numbers?
Here is another Java program to find prime numbers and print them. By using logic demonstrated in this program; you can write similar program in C and C++.
23) Write function to compute Nth Fibonacci number? Both iterative and recursive?
Check this Java program to print Fibonacci Series using recursion and iteration.

General Programming Interview Questions
In this category of programming questions I have put questions which are not fit into any data structure but presents a real life problem and you need to provide solution. These programming questions are sometime based on problems faced by developer itself. I have not included many Software design related programming question which I have shared on Top 20 software design questions and answers; you can also check that.

24) Write a program to find out if two rectangles R1 and R2 are overlapping?
35) You need to write a function to climb n steps you can climb either 1 step at a time or 2 steps a time, write a function to return number of ways to climb a ladder with n step.
26) Write code for Generate Random No in a range from min to max?
27) Write program for word-wrap which should work on any screen size?
28) Design an algorithm to find the frequency of occurrence of a word in an article?
29) Write a program to implement blocking queue in Java?
30) Write a program for producer-consumer problem?


Kindly Share This Post »»

Responses

0 Respones to "Frequently Asked Java C C++ Top 30 Programming Questions asked in Interview with Answers"

Post a Comment

 
HOME | Freshers | Exp | Java | SQL | Walkins | OffCampus | BankJobs
=*= PRIVACY POLICY And DISCLAIMER =*=
Some of the stuff contained this site are found on internetThis site is not responsible for publishing all available Information as well accuracy, please check posted Information with its original sources, e.g. News Papers/ Websites etc.We collect all the Information form the Internet.
Software My Zimbio
Copyright © 2013 Career+ Blog +Google | Disclaimer | Privacy Policy | Contact