Interview Questions and Answers - Order By Newest Q131. Write an SQL to find all records having all upper case alphanumeric characters in a field ?
Ans. Select * from Table where field = upper(field) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql   database Q132. Write an SQL to find all records having all numeric characters in a field ?
Ans. Select * from Table where isnumeric(field) = 1; Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql   database Q133. What are the conventions regarding constant variables or static final variables ? Core Java
Ans. They should be named all in upper case with underscore separating words.
Moreover the name should be such that it identifies the value. For example, if we are using constant for employee Id 123, it should be named something like EMPLOYEE_ID_123 and not EMPLOYEE_ID Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  constants   variable names   java conventions Q134. Do you know of any DB statement that can be used if we would like to insert multiple rows into a table ? Database
Ans. We can use INSERT ALL. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database   insert   dml statement   sqlAns. A Closeable is an interface which is a source or destination of data that can be closed. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  closeable   interfaces intermediate   rare Q136. What is the advantage of JPA ? Database
Ans. Its a specification that guides the implementation of ORM frameworks. Implementations abiding by the specification would mean that one can be replaced with other in an application without much hassle. Only the Features that are added over the specification needs to be taken care of if any such change is made. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  jpa   hibernate   orm   technologies Q137. Why is a constant defined as a static final in Java? Core Java
Ans. Final makes sure that the value doesn't change after initialization and static makes sure that there is only one copy that can be shared across objects. Making it non static will unnecessarily create a different copy per object wherein the same value will kept for all copies ( as its final and cannot be changed ). Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   static   final variables   variable constants basic   frequent Q138. What things you will look for if you get following exception while making DB call ? table or view does not exist Database
Ans. First will check if the table or view actually exist in the DB If it does , Will make sure to see that the application has rights on the schema that holds the respective Table. Will then make sure that we have prefixed the schema with the table name while accessing it. Will then make sure that its not DB Cache that's causing it as the table DDL might have been created recently. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql   database   oracle   technical lead Q139. What's the benefit for specifying constraints like Not Null , Primary Key explicitly instead of specifying it against the column ? Database
Ans. In case we specify them explicitly we can have control over constraint name as otherwise they will be system generated. It provides an ease in case we plan to drop the constraint in future. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql   database   oracle Q140. How can we disable a constraint ? Database
Ans. alter table table_name DISABLE constraint constraint_name; Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql   database   oracle Q141. Can we have foreign key reference to a non primary key column ? Database
Ans. Yes, but the respective key in the foreign table should be declared Unique. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql   database   oracle Asked in 2 Companies Q142. What should be done for auto generating primary key id in a table ? Database
Ans. We need to create a sequence. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql   database   oracle Q143. Which constraint cannot be specified as an explicit constraint and should be specified with the column only ? Database
Ans. NOT NULL Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql   oracle   database   ddl   constraint   table creation Q144. Will this code compile ? public class BuggyBread1{ abstract public void test(); } Core Java
Ans. No. It will give the compilation error saying "The abstract method test in type BuggyBread1 can only be defined by an abstract class". We need to declare the class abstract for it to have any abstract method. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   abstract class   abstract methods   java compilation error Q145. Will this Code compile ? abstract public class BuggyBread1{ abstract public void test(){}; } Core Java
Ans. No. This will give a compilation error saying "Abstract methods do not specify a body". Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   abstract classes   abstract methods   java compilation error   java coding   java code   coding   yes-no Q146. How to know the structure of a Table in Oracle ? Database
Ans. DESC Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql   database   oracle Q147. How to know the constraints on a Table in Oracle ? Database
Ans. SELECT * FROM user_constraints WHERE table_name = '' Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql   database   oracle Q148. How to know the default column value of a Table in Oracle ? Database
Ans. Select DATA_DEFAULT from DBA_TAB_COLUMNS where TABLE_NAME = '' and COLUMN_NAME=''; Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql   database   oracle Q149. How do we specify the criteria if it involves mapping between two entities or join between tables ? Hibernate
Ans. The following code returns the list of Employee objects having employee name starting with A and Dept Name ( Department , Employee Mapped ).
session.createCriteria(Employee.class,"emp")
.createAlias("emp.department", "dept",Criteria.INNER_JOIN)
.add( Restrictions.like("name", "A%") )
.add(Restrictions.eq("dept.name","Finance")
.list(); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   hibernate criteria   hibernate table mapping Q150. Name few classes that implement Cloneable interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_58.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   cloneable  cloning Q151. Name few classes that implement iterable interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_45.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   iterable Q152. What are stateless objects ? How are they different from immutable objects ? Which of these two is thread safe ? Object Oriented Programming
Ans. Stateless objects are the objects without instance fields (instance variables). The class may have compile time constants i.e static final fields.Immutable objects are the objects which have state but the state cannot be changed after initialization. Both are Thread safe. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   stateless objects   immutable  immutability objects   objects   singleton scopeAns. They can be shared across multiple threads as they are thread safe. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   stateless objects   immutable  immutability objects   objects Q154. If we add Enum constants to a sorted collection ( Treemap , TreeSet ), What will be the order in which they will be maintained ? a. Sorted Collection wont maintain them in any order. b. Insertion Order c. Order in which constants are declared. d. Natural Sorting Order.
Ans. Order in which constants are declared. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  enum   collections   sorted collections   treemap   treeset   compareto   comparable   java Q155. Which interface does java.util.Hashtable implement ? a. List b. Set c. Collection d. Map Core Java
Ans. Map Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hashtable   java   collections Q156. Which of the following is false ? a. HashMap came before HashTable. b. HashMap allows null values whereas Hashtable doesn’t allow null values. c. HashTable and HashMap allow Key-Value pairs. d. Hashtable is synchronized whereas HashMap is not.
Ans. HashMap came before HashTable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  map   hashmap   hashtable   collection   java Try 2 Question(s) Test Q157. Which of the collections allows null as the key ?
a. HashTable
b. HashMap
c. TreeMap
d. LinkedHashMap Core Java
Ans. HashMap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map  hashtable Asked in 2 Companies basic   frequent Q158. Which of the following is not a Table tag ? a. th b. td c. tb d.
Ans. tb Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  html   table   html tags Q159. Variables of an interface are intrinsically ...
a. transient
b. final
c. public
d. static
Ans. b,c and d i.e final , public and static Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   interface   interface variables Q160. Which of the following class creates mutable objects ? a. Boolean b. File c. String d. StringBuffer
Ans. StringBuffer Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   immutable  immutability