Interview Questions and Answers - Order By Rating Q211. Write an algorithm to shift a linked list n positions. Data Structure
This question was recently asked at 'Amdocs'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q212. Given 3 arrays - A, B and C, Write all elements from C that are a sum of 1 element from A and 1 from B.
For example -
A -[1,2,4,6]
B-[3,9]
C-[2,4,5,6,7,9,10,12,15]
Output - 4,5,7,9,15
Ans. public class MyClass {
static boolean binarySearch(int [] c, int start, int end, int value) {
while (start <= end) {
int mid = (start end) / 2;
if (c[mid] == value) {
return true;
}
if (c[mid] > value) {
end = mid - 1;
} else {
start = mid 1;
}
}
return false;
}
public static void main(String args[]) {
int [] a = new int[] {1,2,4,6};
int [] b = new int[] {3,9};
int [] c = new int[] {2,4,5,6,7,9,10,12,15};
for (int i = 0; i < a.length; i ) {
for(int j = 0; j < b.length; j ) {
int value = a[i] b[j];
boolean find = binarySearch(c, 0, c.length - 1, value);
if (find) {
System.out.print(value " ");
}
}
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q213. Write a program to rotate a matrix. Core Java
Ans. public class Matrix {
public static void main(String[] args) {
int[][] matrix = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};
Matrix.rotateMatrix(matrix);
for (int i = 0; i < matrix.length; i ){
for (int j = 0; j < matrix.length; j ){
System.out.print(matrix[i][j] " ");
}
System.out.println();
}
}
public static void rotateMatrix(int[][] matrix){
int row = matrix.length;
//first find the transpose of the matrix.
for (int i = 0; i < row; i ){
for (int j = i; j < row; j ){
int temp = matrix[i][j];
matrix[i][j] = matrix[j][i];
matrix[j][i] = temp;
}
}
//reverse each row
for (int i = 0; i< row; i ){
for(int j = 0; j< row/2; j ){
int temp = matrix[i][j];
matrix[i][j] = matrix[i][row - 1 - j];
matrix[i][row - 1 - j] = temp;
}
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q214. What is the time complexity and space complexity of reversing a Linked List ? Data Structure
Ans. o(n) for time complexity
o(1) for space complexity Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   This question was recently asked at 'Fujitsu'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q216. How do you achieve String immutability ? Core Java
This question was recently asked at 'Polaris'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q217. Can we override behavior of a collection class ? How ? Core Java
Ans. Yes. We can do that.
1. We can create own own implementation class extending the collection class and then override the behavior method.
2. We can override the behavior at the time of instantiation of class as following
List<MyType> list = new ArrayList<MyType>() {
public boolean add(MyType mt) {
super.add(mt);
Collections.sort(list, comparator);
return true;
}
}; Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collections Q218. Explain Rest architecture Rest
This question was recently asked at 'Motorola Solutions,DXC Technology'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 2 Companies Q219. What is Spring Security in Detail ?
This question was recently asked at '3i Infotech'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q220. Explain unix commands - cat and pwd. Unix
Ans. by using Cat command we can open and see the file content and as well as redirect the file content to another files
pwd command shows us current working path of the server
cat filename | tail -100
cat file name > filname1 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q221. What is the difference between map and filter methods in streams ? Core Java
Ans. By using map , you can transform the object values. The map operation allows us to apply a function, that takes input parameter of one type, and returns something else.
Filter is used for filtering the data, it always returns the boolean value. If it returns true, then item is added to list else its filtered out (ignored) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java 8 Asked in 1 Companies This question was recently asked at '360Degree'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q223. How many objects are created when we define a bean with two different name in spring? Spring
Ans. we wont create the objects because of each and every bean will be an object Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q224. what annotation do in background in hibernate ? Hibernate
This question was recently asked at 'Cdac Pune'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Ans. Message queues implement an asynchronous communication pattern between two or more processes/threads whereby the sending and receiving party do not need to interact with the message queue at the same time. Messages placed onto the queue are stored until the recipient retrieves them. Message queues have implicit or explicit limits on the size of data that may be transmitted in a single message and the number of messages that may remain outstanding on the queue. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  message queue Asked in 1 Companies Q226. What are the difference between "resetting" and "normalizing" CSS? CSS
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q227. How to track immediate parent of the child in selenium using xpath? Selenium
Ans. Using ./ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q228. Why Spring boot is preferred over Spring MVC ?
Ans. Spring Boot aims to shorten the code length and provide you with the easiest way to develop a web application. It helps create a stand-alone application with less or almost zero-configuration. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q229. Does spaces get's encoded in html encoding ? Encoding
Ans. Yes they get html encoded. i.e instead of empty space. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q230. What is the difference between html encoding and url encoding ? Encoding
Ans. HTML Encoding escapes special characters in strings used in HTML documents whereas url Encoding replaces special characters with characters so that they can sent within url. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q231. Can you share your experience with encoding and encryption ? Encoding
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  encoding  encryption Q232. Can we change permissions recursively for all folders and files within a single folder ? Unix
Ans. chmod 777 -R /directory Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Unix Commands Q233. How do you ftp files to a different server ? Do you use scp or mput etc. Unix
Ans. I use both mput as well as scp. mput usually with sftp Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  unix commands  ftp Q234. How would you handle clustering on multiple servers? Server
This question was recently asked at 'Sifi'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  production support Asked in 1 Companies Q235. Explain how a class is loaded ? Core Java
Ans. Java classLoder is resposible to load java classes. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q236. Difference between constructor and method ?
This question was recently asked at 'Fog Creek,IBM India,Cubic,Zymergen,Parexel '.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 5 Companies Q237. What is stress testing ? Testing
Ans. Stress testing is a software testing activity that determines the robustness of software by testing beyond the limits of normal operation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q238. What if we use all access specifiers ? Is it encapsulation ? Core Java
This question was recently asked at '3 Embeded Software Technologies'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q239. Difference between class and object with example. Core Java
This question was recently asked at 'TalenPace'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q240. Is there a way to access a private method from an outside class ? Core Java
Ans. Through Reflection. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies