Interview Questions and Answers - Order By Newest Q1261. Create a custom hashmap using synchronization. Core Java
This question was recently asked at 'Deutsche Bank'.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  hashmap  coding Asked in 1 Companies advanced Ans. https://dzone.com/articles/jvm-architecture-explained Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies This question was recently asked at 'jspiders'.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 basic   frequent Q1264. What is collection framework in Java ? Core Java
Ans. The Java collections framework (JCF) is a set of classes and interfaces that implement commonly reusable collection data structures. Although referred to as a framework, it works in a manner of a library. The JCF provides both interfaces that define various collections and classes that implement them. Sample Code for Map Sample Code for HashMap Sample Code for Treemap Sample Code for set Sample Code for hashset Sample Code for treeset Sample Code for list Sample Code for arraylist Sample Code for linkedlist Sample Code for queue Sample Code for priorityqueue Sample Code for concurrenthashmap Sample Code for vector Sample Code for stack Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collections Asked in 9 Companies basic   frequent Q1265. What is the difference between Java and J2ee ? Java EE
This question was recently asked at 'Sunovaa Tech'.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  java vs j2ee  java  j2ee Asked in 1 Companies Ans. It is a file format based on the popular ZIP file format and is used for aggregating many files into one. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  jar Asked in 1 Companies basic This question was recently asked at 'American International Group (AIG)'.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  applet Asked in 1 Companies basic   rare Q1268. What is the purpose of JDP and JDK ? Core Java
This question was recently asked at 'Dextrasys'.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  jdp  jdk Asked in 1 Companies Ans. The interface is a mechanism to achieve abstraction. Interfaces can have abstract methods and variables. It cannot have a method body. Sample Code for interface Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  interface Asked in 1 Companies basic   frequent This question was recently asked at 'MST Solutions'.This question is still unanswered. Can you please provide an answer. Sample Code for composition Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  composition  object oriented programming (oops)  oops concepts  oops concepts Asked in 1 Companies basic   frequent Q1271. In the Following code which foo will get called.
foo(Integer i){
}
foo(String s){
}
public static void main(){
passing foo(null);
} Core Java
Ans. ambiguity error Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  code  method  function  data types Asked in 1 Companies Q1272. Can you give a real life example of synchronization Core Java
Ans. Intersection with traffic light Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  synchronization Q1273. How do you define a functional interface? Core Java
Ans. Create interface with the only one non-overriding abstract method and annotate it with @FunctionalInterface Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  functional interface  java 8 Asked in 1 Companies This question was recently asked at 'adobe'.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  vector  collections  list Asked in 1 Companies Ans. Overriding refers to the Methods with same name and parameters, such that the later over rides the former method. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  oops  oops concepts  overriding Asked in 1 Companies basic   frequent Ans. The process of hiding the implementation details from the user and providing only functionality. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies basic   frequent Q1277. Can we modify a list while iterating it ? Core Java
Ans. No,we cannot.I t will give concurrentModificationExceptin error. It can be resolved by using ConcurrentClasses like ConcurrentHashMap,CopyOnWriteArrayList,BlockingQueue etc which are fail-safe and wont give exception. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collections  list  iterator Asked in 1 Companies basic Q1278. What are the characteristics of the object ? Core Java
Ans. 1. State
Instance variable or member elements forms the object state.
2. Behavior
Member functions forms the object behavior
3. Identity
Every object has a unique identity within JVM through a unique Id. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  oops  oops concepts Q1279. How can we make objects if the constructor is private ? Core Java
This question was recently asked at 'Nagravision'.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  constructor Asked in 1 Companies Q1280. Why String is a class in Java ? Core Java
This question was recently asked at 'NIIT 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 Q1281. Write a Program to find number of lines , words and characters in a File. Core Java
Ans. import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class FileUtility {
public static void main(String[] args) {
System.out.println(printFile("/home/userme/notes"));
}
private static int printFile(String filePath) {
int wordCount = 0;
try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
String line = null;
String[] wordsArray = null;
while ((line = br.readLine()) != null) {
wordsArray = line.split(" ");
wordCount = wordsArray.length;
}
} catch (IOException e) {
e.printStackTrace();
}
return wordCount;
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  code  coding Asked in 2 Companies Q1282. Given a String with some Code, Write a Parser to have proper indentation. Core Java
This question was recently asked at 'Facebook'.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 Q1283. How do you make instance of an abstract class ? Core Java
Ans. By extending it to the derived class and thereby creating instance of derived class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1284. Explain how Mark & Sweep is implemented in garbage collection. Core Java
This question was recently asked at 'Amazon'.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 Q1285. How would you stop a Thread in java ? Core Java
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   Q1286. Write code for serialization. Core Java
Ans. // Java code for serialization and deserialization
// of a Java object
import java.io.*;
class Demo implements java.io.Serializable
{
public int a;
public String b;
// Default constructor
public Demo(int a, String b)
{
this.a = a;
this.b = b;
}
}
class Test
{
public static void main(String[] args)
{
Demo object = new Demo(1, "geeksforgeeks");
String filename = "file.ser";
// Serialization
try
{
//Saving of object in a file
FileOutputStream file = new FileOutputStream(filename);
ObjectOutputStream out = new ObjectOutputStream(file);
// Method for serialization of object
out.writeObject(object);
out.close();
file.close();
System.out.println("Object has been serialized");
}
catch(IOException ex)
{
System.out.println("IOException is caught");
}
Demo object1 = null;
// Deserialization
try
{
// Reading the object from a file
FileInputStream file = new FileInputStream(filename);
ObjectInputStream in = new ObjectInputStream(file);
// Method for deserialization of object
object1 = (Demo)in.readObject();
in.close();
file.close();
System.out.println("Object has been deserialized ");
System.out.println("a = " object1.a);
System.out.println("b = " object1.b);
}
catch(IOException ex)
{
System.out.println("IOException is caught");
}
catch(ClassNotFoundException ex)
{
System.out.println("ClassNotFoundException is caught");
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  serialization Asked in 1 Companies Q1287. If compareTo() method returns zero, does it mean that the objects are always equal? Core Java
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   Q1288. Write a method receiving a stream of integers, caching the last 10 min of data and returning a number if it's less than the current input Core Java
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   Q1289. How would you write a socket in Java Core Java
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   Q1290. Why do you think lambda expressions are considered such a big thing for Java 8? Core Java
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