Core Java - Interview Questions and Answers for 'Core Java' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Interview Questions and Answers - Order By Newest

   next 30
 Q931. 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     


 Q932. What are the drawbacks of creating immutable objects ? Why don't we create all object immutable if mutability possesses so much threat ? Core Java
Ans. Immutable objects relieves us from the problems of inconsistencies and security and helps with better read performance but at the same time are write performance and storage overheads. In case any modification is required , a new object is created and thus creating multiple copies of it.

This is the reason we use StringBuffer / StringBuilder when we have to append some text multiple times and then create a String out of it.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     immutable  immutability objects  immutability


 Q933. Does immutability facilitates better performance ?Core Java
Ans. Yes , but only the read performance in case we don't need to modify it much. In case we need to modify it a lot , it creates write performance overheads as we would need to create many news objects instead of just changing one.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     immutable  immutability objects  immutability


 Q934. Do you think that Recursion is expensive on computation ?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     


 Q935. Write a program to rotate array elements clockwise.Core Java
Ans. class Rotate{

void leftRotate(int arr[], int d, int n)
{
for (int i = 0; i < d; i )
leftRotatebyOne(arr, n);
}

void leftRotatebyOne(int arr[], int n)
{
int i, temp;
temp = arr[0];
for (i = 0; i < n - 1; i )
arr[i] = arr[i 1];
arr[i] = temp;
}


void printArray(int arr[], int n)
{
for (int i = 0; i < n; i )
System.out.print(arr[i] " ");
}


public static void main(String[] args)
{
Rotate rotate = new Rotate();
int arr[] = { 1, 2, 3, 4, 5, 6, 7 };
rotate.leftRotate(arr, 2, 7);
rotate.printArray(arr, 7);
}
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q936. Given an array with number 1 to n, find the missing numbers. Core Java
Ans. int main ()
{
int a []={1..n};
int miss=getMiss (a,n);
Printf ("%d",miss);
}
getMiss (int a [],int n){
int I,total;
total=(n 1)*(n 2);
for (i = 0; i < n; i++)
total -= a[i];
return total;
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q937. Write a program to find the 10th prime number.Core Java
Ans. import java.util.Scanner;
public class Prime
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter n to compute the nth prime number: ");
int nth = sc.nextInt();
int num, count, i;
num=1;
count=0;

while (count < nth){
num=num 1;
for (i = 2; i <= num; i )
{
if (num % i == 0)
{
break;
}
}
if ( i == num)
{
count = count 1;
}
}
System.out.println("Value of nth prime: " num);
}
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q938. Write a program to find length of String without using library function.Core Java
Ans. Class lengofstring {
Public static void main(String[] arr) {
int i = 0;
String s = "hello world!";
for (char C: s.toCharArray()) i;
System.out.println("Length: "
i);
}
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q939. Write a custom exception.Core Java
Ans. if you are creating your own exception is known as custom exception.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q940. What is an exception ? What are the different types of exceptions ?Core Java
Ans. An exception is an unwanted or unexpected event, which occurs during the execution of a program that is at run time, that disrupts the normal flow of the program?s instructions. these are different types arithmetic exceptions, class not found exception, interrupted exception, run time exception etc.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q941. Why use Java ?Core Java
 This question was recently asked at 'Improwea'.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


 Q942. Why do we need ConcurrentHashMap ?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     


 Q943. What is the default size of ArrayList ?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     


 Q944. Find minimum operations required to convert one string to another. Allowed operation :Insertion Deletion Replace, all operational costs are same.Core Java
Ans. StringBuilder str = new StringBuilder("Pizza");
int size = str.length();
str = str.replace(size-1, size, "u");
System.out.println("After replace, str = " str); // prints Pizzu

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q945. Write code to read data from a file and write it to a file with 2 threads using the thread name contentCore Java
 This question was recently asked at 'verifone'.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     threads  file  file handling     Asked in 1 Companies


 Q946. What is the difference between Interfaces and Abstract Classes with respect to 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     


 Q947. Which of the OOP's feature - encapsulation or abstraction - is more important ?Core Java
Ans. Encapsulation facilitates security by hiding data and logic whereas Abstraction simplifies organization of data and related logic.

As applications scale, both concepts are required for easy management and maintenance. Encapsulation for security and criss cross communication between objects / modules will make it vulnerable. and Abstraction for better organization that enables better understanding of application code and easy maintainability.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     oops  oops features  oops concepts


 Q948. Which of the polymorphism type - static or runtime - is more important ?Core Java
Ans. Method overloading / static polymorphism compared to method overriding / runtime polymorphism has very limited usage as it just opens up an alternate way of defining a different method with the same name.

Method Overriding on other hand opens up many other features like contracting , interfacing , pluging development and hence development of libraries and frameworks.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     oops  oops features  oops concepts


 Q949. What is the reason that non-static method are not allowed to be referenced from a static context in Java?
Core Java
Ans. If we try to access an instance method from a static context , the compiler has no way to guess which instance method ( variable for which object ), you are referring to. Though, you can always access it using an object reference.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q950. Which are the thread safe / synchronized / concurrent classes in java collections ?Core Java
Ans. Stack
Properties
Vector
BlockingQueue
ConcurrentMap
ConcurrentNavigableMap

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     collections  concurrent classes


 Q951. What are the differences between Intermediate and Terminal Operations in Java 8 streams?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     


 Q952. What is the difference between Collections.emptyList() and creating instance of a list ?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     


 Q953. Which are the classes that implement java.util.List interface ?Core Java
Ans. ArrayList
LinkedList
Vector
Stack

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q954. Why do you think that Stack collection class implement List interface ? 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     


 Q955. What is the there only one method declared in Runnable interface? Core Java
Ans. The Runnable interface describes a class whose instances can be run as a thread. The interface itself is very simple, describing only one method ( run ) that is called automatically by Java when the thread is started. The Runnable interface is usually used in conjunction with the Thread class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q956. What is difference between Executor.submit() and Executer.execute() method ?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     


 Q957. What is difference between CyclicBarrier and CountDownLatch 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     


 Q958. What do you mean by synchronized Non Access Modifier?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     


 Q959. Name few classes of java.util.regex package ?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     


 Q960. Is String thread-safe?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     


previous 30   next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: