Interview Questions and Answers - Order By Newest Q1051. Write a Program to print count of each character in a String. Core Java
Ans. public class BuggyBread {
public static void main(String args[]) {
Map<Character, Integer> countMap = new HashMap();
String str = "hello world";
for (char character : str.toCharArray()) {
if (countMap.containsKey(character)) {
countMap.put(character, countMap.get(character) + 1);
} else {
countMap.put(character, 1);
}
}
System.out.println(countMap);
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  String  Code  Coding  Character Asked in 1 Companies Q1052. Write a program for 0 and cross games? Core Java
This question was recently asked at '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  code.coding.0 and cross game Asked in 1 Companies Q1053. Write Code showing Inheritance Core Java
Ans. class A {
public void test() {
System.out.println("Class A Test");
}
}
class B extends A {
public void test() {
System.out.println("Class B Test");
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1054. Write a Program / Code showing Inheritance and overridding Core Java
Ans. class A {
public void test() {
System.out.println("Class A Test");
}
}
class B extends A {
public void test() {
System.out.println("Class B Test");
}
public static void main(String[] args){
A a = new B();
a.test(); // will print Class B Test
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1055. Create a Table with 2 Columns and Insert a row into it Database
Ans. CREATE TABLE TABLE_NAME (
ID NUMBER PRIMARY KEY,
NAME VARCHAR(50) NOT NULL,
);
INSERT INTO TABLE_NAME(ID, NAME) VALUES(1, "Abc"); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ddl  dml  create table  insert records into table Asked in 1 Companies Q1056. What is the difference between circular queue and priority queue ? Data Structures
Ans. https://qr.ae/TWK2Ok Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  circular queue  priority queue  queue  data structures  collections Q1057. What are the different primitive data types in Java ? Core Java
Ans. boolean
byte
char
double
float
int
long
short
void Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  data types  primitive data types Asked in 1 Companies Basic Q1058. What is a method reference in Java ? Core Java
Ans. Introduced with java 8 , Method References help us to point to methods by their name.
A method references is described using :: symbol Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  method reference  java 8  lambda expressions Q1059. Write a Program to print duplicate words in a String Core Java
Ans. public class BuggyBread {
public static void main(String args[]) {
String str = "we are what we repeatedly Do excellence, then, is not an act but a haBit";
Set<String> words = new HashSet();
for(String word:str.split(" ")){
if(words.contains(word)){
System.out.println(word);
} else {
words.add(word);
}
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1060. Write code to find second largest number in an array of integers. Core Java
Ans. int arr[]={1,3,5,6,4,8,9,2,10};
Arrays.sort();
System.out.println(arr[arr.length-1]); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  code  coding  find in array Asked in 1 Companies Q1061. What are the different types of log files you have come across ? Logging
Ans. error , access , authentication , message , database etc Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  logging  log files  types of log files Q1062. Difference between concurrentHashMap and HashTable ? Core Java
Ans. HashTable locks the complete collection to provide synchronization whereas ConcurrentHashMap only locks segments to achieve synchronization and hence better efficient and faster. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  concurrentHashMap  HashTable  Map  Collections Asked in 2 Companies Q1063. isnt the use of HashTable and ConcurrentHashMap the same, i.e providing synchronized map collection ? Core Java
Ans. Yes, they both aim at providing synchronized access to the Map collection. The only difference is in their implementation. ConcurrentHashMap came after HashTable and hence technically more efficient as it doesn't lock the complete map while accessing it. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  HashTable  ConcurrentHashMap  map  Collections Q1064. What are the advantages of Spring interceptor over Servlet Filters ? Spring
Ans. Spring Interceptor are Spring beans and hence they can inject other beans and can be used with other Spring frameworks concepts like AOP. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  interceptors  servlet filters  spring interceptors vs servlet filters Q1065. Upon compiling the following class, What .class files will get created
public class OuterClass{
class InnerClass{
}
}
Core Java
Ans. OuterClass.class AND OuterClass$InnerClass.class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  class files  compilation  compile  inner classes   nested classes Q1066. Write a Program to validate an email address Core Java
Ans. public class Class{
public static void main(String[] args){
String str = "xyz@123.com";
if(!str.contains("@") && !str.contains(".") && (str.indexOf('.') < str.indexOf('@'))){
System.out.println("Not a Valid Email Address");
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  validate an email address  coding  code Asked in 3 Companies Q1067. Difference between Singleton and Factory Design Pattern ? Design
Ans. Both are creational design patterns but singleton facilitates in creation and reuse of single object whereas Factory deals with creation of multiple objects. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Design pattern  singleton  factory  singleton vs factory Asked in 4 Companies Q1068. What is dynacache and role of cachespec.xml in WCS ? IBM WCS
Ans. Dynacache in WCS is the object cache. Instead of creating objects again and again , the store objects are rendered on the basis of matched rules. Caching rules are stored in a configuration file called cachespec.xml. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  dynacache  cachespec.xml Q1069. How to enable Cross Site scripting protection in WCS ? IBM WCS
Ans. By specifying XSiteScriptingProtection within wc-server.xml. Prohibited characters and attributes are specified within XSiteScriptingProtection to protect the application from any XSS attach. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Cross site scripting  XSS attack  XSS  XSiteScriptingProtection  wc-server.xmlAns. Its the Store Archive that holds the store Assets in the compressed form. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  SAR file  store archieveAns. Selling of Merchandise across stores. For example - Store A selling Store B's merchandise. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  cross selling  order management  ecommerce Q1072. Describe Catalog subsystem and the tables used in WCS for managing this ? IBM WCS
Ans. The catalog subsystem or Catalog Management provides online catalog navigation, partitioning, categorization, and associations. In addition, the catalog subsystem includes support for personalized interest lists and custom catalog display pages. The catalog subsystem contains all logic and data relevant to an online catalog, including catalog groups (or categories), catalog entries, and any associations or relationships among them.
Tables used for Catalog subsystem
1. CATENTRY
2. CATENTREL Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  catalog subsystem Q1073. Is it necessary to register controller command in CMDREG table ? IBM WCS
Ans. It is not necessary to enter data in the CMDREG table, but an entry should be made in the struts-config.xml. The controller command can be registered in the CMDREG table by xml and SQL query. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  controller commands  CMDREG Q1074. What are the tag libraries used in WCS ? IBM WCS
Ans. Core tags, sql , xml and fmt tags. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  wcs tag librariesAns. acugload is the utility to load the user access group in the appropriate database. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  acugload Q1076. Write a Program to find the missing integer in an array of consecutive numbers? Core Java
This question was recently asked at 'Knight Capital'.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 Q1077. How to find the median number in an array of integers ? Core Java
Ans.
Arrays.sort(numArray);
double median;
if (numArray.length % 2 == 0)
median = ((double)numArray[numArray.length/2] (double)numArray[numArray.length/2 - 1])/2;
else
median = (double) numArray[numArray.length-1/2]; Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  coding Asked in 2 Companies Q1078. Write a Java program to print 10 random numbers between 1 to 100? Core Java
This question was recently asked at 'karya 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  coding  code Asked in 1 Companies Q1079. Why don't Java objects have destructors ? Core Java
Ans. Java manages memory using built-in garbage collector Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  destructor  garbage collection Q1080. What is the difference between && and & in Java ? Core Java
Ans. && is a Logical whereas & is a bitwise operator Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  operators  logical vs bitwise operator