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.
Ans. Lazy Initialization means , Load Dependencies when required. Which means less load on application resources as only required data is loaded upfront. It's not only good for better performance but for better resource utilization too.
Help us improve. Please let us know the company, where you were asked this question :
Ans. 1. Security and Safety - They can be shared across multiple threads as they are thread safe. Moreover, it protects then from bad state due to interception by the other code segment. One such problem due to mutability and access by alternate code segment could be the change of hash code and then the impact on its search with hash collections.
2. Reuse - In some cases they can be reused as only one copy would exist and hence it can be relied upon. For example - String Pool
Help us improve. Please let us know the company, where you were asked this question :
Ans. String class has a public method intern() that returns a canonical representation for the string object. String class privately maintains a pool of strings, where String literals are automatically interned.
these are automatically interned so as to have efficient String comparison using == operator instead of equals which is usually slower.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Product refer to category of Items and hence can't be associated to a particular Stock keeping unit. Items can only be targeted while creating promotions.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Compilation is the process of converting Java source files to class files which can be executed by the Java runtime environment whereas Decompilation is the process of converting class files back to the Java Source code.
Help us improve. Please let us know the company, where you were asked this question :
Ans. public class Class{
public static void main(String[] args){
List<Integer> collector = new ArrayList();
Scanner scanner = new Scanner(System.in);
int x = scanner.nextInt();
while(x != 0){
collector.add(x);
x = scanner.nextInt();
}
System.out.println(collector.stream().collect(Collectors.averagingInt(p->((Integer)p))));
}
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. public class Class{
public static void main(String[] args){
String string1 = "Hello I am Jack. I live in United States. I live in california state.";
String string2 = "I live in";
if(string1.indexOf(string2) >= -1){
System.out.println("string2 is sub string of string1");
} else {
System.out.println("string2 is not sub string of string1");
}
}
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. public class Class{
public static void main(String[] args){
String string1 = "Hello I am Jack. I live in United States. I live in california state.";
String string2 = "I live in";
int startIndex = 0;
int endIndex = string1.length()-1;
Q1313. Write a Program to check if string is a Colidrome ?
(Colidrome is a word that has n alphabets followed by the reverse of the n alphabets, for ex - mallom)
Ans.
public class Class {
public static void main(String[] args) {
String str = "mallam";
String firstHalf = str.substring(0, str.length() / 2);
String secondHalf = str.substring(str.length() / 2);
if (firstHalf.equals(new StringBuilder(secondHalf).reverse().toString())) {
System.out.println("It's a Colidrome");
} else {
System.out.println("It's not a Colidrome");
}
}
}
Help us improve. Please let us know the company, where you were asked this question :
Q1314. Write a program in Java that prints the numbers from 1 to 100. But for multiples of three print Fizz instead of the number and for the multiples of five print Buz. For numbers which are multiples of both three and five print FizzBuzz
Ans. public class BuggyBread{
public static void main (String args[]) {
Set<Character> set = new HashSet();
Set<Character> setWithDuplicateChar = new HashSet();
String str = "hello world";
for(char character: str.toCharArray()){
if(set.contains(character)){
setWithDuplicateChar.add(character);
} else {
set.add(character);
}
}
System.out.println(setWithDuplicateChar);
}
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. Performance of a system doesn't solely rely on size of processor or it's communication size. It should also be compatible with other resources like memory, storage etc. Moreover it makes no sense to have 64 bit systems when there is hardly any software than can run on 64 bit system.
Help us improve. Please let us know the company, where you were asked this question :