Interview Questions and Answers - Order By Rating Q1591. What could be the problems due to the usage of static methods and elements ? Core Java
Ans. static methods and static elements are shared by all objects of a class and hence could create problem.
Static methods are not synchronized by default and hence could create problem when accessed through multiple threads. Static elements are shareable by class and hence state of one object could be altered by another object.
Some limitations with Unit testing as not all mocking framework facilitate mocking them. Power mock allows but Mockito doesn't Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  static  static method  static variables Q1592. Difference between Maven and Ant ? Maven
Ans. Ant is procedural, we need to provide information about what to do and when to do through code.
Maven is declarative, everything is defined in the pom file. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  maven  maven vs ant Asked in 1 Companies Q1593. What is Maven ? Maven
Ans. Maven is a build automation tool used primarily for Java projects. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  maven  build Asked in 6 Companies basic   frequent Ans. Spring Boot is Springs convention-over-configuration solution for creating stand-alone, production-grade Spring-based Applications. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Spring Boot Asked in 7 Companies Q1595. Explain some of the http status codes you know ? Java EE
Ans. 500 is Internal Server Error
404 is resource not found
400 is Bad Request
403 is Forbidden
401 is Unauthorized
200 is OK Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  http  http status codes Asked in 2 Companies   frequent Q1596. Write a Program to print the positive and negative numbers separetly Core Java
Ans. int[] arr = {1,-1,2,-3,3,-4,4,5,6,-5,-6,-7,-8,8,9,-9};
List positiveNumbers = new ArrayList<>();
List negativeNumbers = new ArrayList<>();
for(int i = 0; i < arr.length(); i ){
if(I < 0){
negativeNumbers.add(i);
} else {
positiveNumbers.add(i);
}
}
System.out.println("Positive Numbers:" + positiveNumbers);
System.out.println("Negative Numbers:" + negativeNumbers); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  code  program  coding Asked in 1 Companies Q1597. What are Collection Classes ? Core Java
Ans. Collections in java is a framework of classes that provides an abstracted data structure to store and manipulate the group of objects. Each class is unique in the way it stores , search , sort and modify the elements. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collections  collection classes Asked in 1 Companies Basic   frequent Q1598. Which method of String class is used to convert Boolean to String ? Core Java
Ans. toString() is an overloaded method of String class that is used to convert many data types to String, Boolean being one of them.
toString(Boolean bool) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  String  String class  Boolean Asked in 1 Companies Basic Q1599. What are fields that gets displayed when you execute "Top" command and briefly explain each field ? Unix
Ans. PID - process identification number is an identification number that is automatically assigned to each process when it is created
USER - User Name
PR - PR is the process actual priority
NI is the nice value, which is a user-space concept.
VIRT -Virtual Image (kb). The total amount of virtual memory used by the task.
RES - Resident size (kb). The non-swapped physical memory a task has used.
SHR - Shared Mem size (kb). The amount of shared memory used by a task.
S - Process Status. The status of the task which can be one of:
D = uninterruptible sleep
R = running
S = sleeping
T = traced or stopped
Z = zombie
%CPU - % CPU usage
%MEM - % MEM Usage
TIME - Total CPU time the task has used since it started.
COMMAND - Command which was used to execute the process Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  top command  unix command Asked in 1 Companies Q1600. Write a unix command to find top 10 files by size ? Unix
Ans. du -a /var | sort -n -r | head -n 10 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  unix command Asked in 1 Companies Q1601. What will be the crontab to run a job every last day of month ? Unix
Ans. 59 23 28-31 * * [ "$(date +%d -d tomorrow)" = "01" ] && job_name Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  unix  crontab Asked in 1 Companies Frequently asked in Accenture. Q1602. What is your biggest achievement at work ? General
Ans. [Open Ended Answer] Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  general question  non technical question Asked in 20 Companies   frequent Q1603. Difference between Error and Exception ? Core Java
Ans. An Error indicates serious problems that a reasonable application should not try to catch whereas
An Exception indicates conditions that a reasonable application might want to catch. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  error  exception handling  exceptions Asked in 2 Companies basic   frequent Q1604. Difference between Array and ArrayList ? Core Java
Ans. <a href="http://javahungry.blogspot.com/2015/03/difference-between-array-and-arraylist-in-java-example.html" rel="nofollow">http://javahungry.blogspot.com/2015/03/difference-between-array-and-arraylist-in-java-example.html</a> Sample Code for ArrayList Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  array  arraylist Asked in 11 Companies basic   frequent Q1605. How to create stateful Rest Services ? Rest
Ans. There is no direct way to make stateful REST service but when first time request send to server, generate the token on server and send back to client. When every time new request is send the token is send to identify the request is coming from same client. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Rest  Web Services Asked in 1 Companies Q1606. Write a Program to print permutations of a String. Core Java
Ans. public static Stream permutations(String str) {
if (str.isEmpty()) {
return Stream.of("");
}
return IntStream.range(0, str.length()).boxed()
.flatMap(i -> permutations(str.substring(0, i) str.substring(i 1)).map(t -> str.charAt(i) t));
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 2 Companies Q1607. How to delete duplicate elements in a table ? Database
Ans. DELETE FROM TABLE WHERE ROW_NUM NOT IN ( SELECT MAX(ROW_ID) FROM TABLE GROUP BY DUPLICATE_FIELD ) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 3 Companies This question was recently asked at 'Myntra,Compro 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 2 Companies Q1609. Flatten a Binary Tree to Linked List Algorithm
Ans. https://www.geeksforgeeks.org/flatten-a-binary-tree-into-linked-list/ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1610. Design a Data Structure for a full text Search ? Design
This question was recently asked at 'Myntra'.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  Full Text Search  Data Structure Asked in 1 Companies expert Q1611. Implement an LRU Cache ? Design
Ans. https://www.programcreek.com/2013/03/leetcode-lru-cache-java/ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1612. What is the difference between http and https ? Java EE
Ans. https encrypts the data using SSL whereas http sends it as plain text, So https is secure protocol whereas http is not.
Moreover https connects on port 443, while HTTP is on port 80 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  http  https  web protocols Asked in 1 Companies   basic Q1613. Write Delegate function of JQuery ? JQuery
Ans. http://www.w3schools.com/jquery/event_delegate.asp Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1614. What is a web service ? Java EE
Ans. A Web service is a service offered by one system to another, for communication over web through http. XML are JSON are usually used for sending across information from one system to another. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  web service Asked in 2 Companies basic   frequent Q1615. How would you process a 20 gb file with an application only having access to 4gb memory ? BigData
Ans. Load the file in chunks and then process. If we need to do analytic, we can process analytic information for those chunks and then reprocess the processed information from each chunk.
For example - we need to average all marks in the file. We can divide the file and load into 5 chunks and calculate average for each chunk. Then we can collect averages for all 5 chunks and then calculate the final average. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  bigdata  processing big data Asked in 1 Companies Q1616. Difference between relational databases and NoSQL databases ? Database
Ans. https://www.mongodb.com/scale/nosql-vs-relational-databases Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database management  nosql database  relational database Asked in 1 Companies   frequent Frequently asked in Alibaba (Based on 2 feedback) Q1617. What is the best Memory setting for JVM ? Core Java
Ans. In Java JVM memory settings is done by use the arguments -Xms -Xmx. Use M or G after the numbers for indicating Megs and Gigs of bytes respectively. -Xms indicates the minimum and -Xmx the maximum. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  jvm  memory management  jvm best memory setting Asked in 1 Companies intermediate Q1618. Can you write a "Hello World" program without using any ";" within it? Core Java
Ans. Yes, That is possible
class A {
public static void main(String args[]){
if(System.out.printf("Hello World")==null){}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Hello World  Hello world without ; Asked in 2 Companies   rare Q1619. What is the difference between following time formats ?
hh:mm:ss
HH:mm:ss
kk:mm:ss
KK:mm:ss Core Java
Ans. hh= hours in 1-12 format
HH= hours in 0-23 format
kk = Hours in 1-24 format
KK= hours in 0-11 format Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Date  Date Time Format  Date Time Q1620. Have you ever tried mocking static methods ? Testing
Ans. Yes, that can be done using Power Mock. Mockito doesnt provide a way to mock static methods. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Mockito  junit  powermock Asked in 1 Companies