Core Java Multiple Choice Questions With Answers 2018

Core Java Multiple Choice Questions With Answers 2018. Here Coding compiler sharing a list of 40 Java Objective Questions and Answers for freshers and experienced Java developers. We hope that these Java MCQ Questions will help you to crack your next Java interview. All the best for your future and happy Java learning.

Core Java Multiple Choice Questions

1) A process that involves recognizing and focusing on the important characteristics of a situation or object is known as:

(a) Encapsulation (b) Polymorphism
(c) Abstraction (d) Inheritance
(e) Object persistence.

A) c

2) Which statement is true regarding an object?

(a) An object is what classes instantiated are from
(b) An object is an instance of a class
(c) An object is a variable
(d) An object is a reference to an attribute
(e) An object is not an instance of a class.

A) b

3) In object-oriented programming, composition relates to

(a) The use of consistent coding conventions
(b) The organization of components interacting to achieve a coherent, common behavior
(c) The use of inheritance to achieve polymorphic behavior
(d) The organization of components interacting not to achieve a coherent common behavior
(e) The use of data hiding to achieve polymorphic behavior.

A) b

4) In object-oriented programming, new classes can be defined by extending existing classes. This is an example of:

(a) Encapsulation (b) Interface
(c) Composition (d) Inheritance (e) Aggregation.

A) d

5) Which of the following does not belong: If a class inherits from some other class, it should

(a) Make use of the parent class’s capabilities
(b) Over-ride or add the minimum to accomplish the derived class’ purpose
(c) Over-ride all the methods of its parent class
(d) Make sure the result “IS-A-KIND-OF” its base class
(e) Make sure the result “contains” its base class.

A) c

6) Object-oriented inheritance models the

(a) “is a kind of” relationship
(b) “has a” relationship
(c) “want to be” relationship
(d) inheritance does not describe any kind of relationship between classes
(e) “contains” of relationship.

A) a

7) The wrapping up of data and functions into a single unit is called

(a) Encapsulation (b) Abstraction
(c) Data Hiding (d) Polymorphism (e) Message passing.

A) a

8) Polymorphism

(a) Is not supported by Java
(b) Refers to the ability of two or more objects belonging to different classes to respond to exactly the same message in different class-specific ways
(c) Simplifies code maintenance
(d) Not simplifies code maintenance
(e) Refers to the ability of two or more objects belonging to different classes to respond to exactly the same message in different class-specific ways and simplifies code maintenance.

A) e

9) In object-oriented programming, new classes can be defined by extending existing classes. This is an example of:

(a) Encapsulation (b) Interface (c) Composition
(d) Inheritance (e) Aggregation.

A) d

10) Given a class named student, which of the following is a valid constructor declaration for the class?

(a) Student (student s) { } (b) Student student ( ) { }
(c) Private final student ( ) { } (d) Void student ( ) { }
(e) Static void student(){ }.

A) a

Core Java Multiple Choice Questions With Answers

11) What is garbage collection in the context of Java?

(a) The operating system periodically deletes all of the java files available on the system.
(b) Any package imported in a program and not used is automatically deleted.
(c) When all references to an object are gone, the memory used by the object is automatically reclaimed.
(d) The JVM checks the output of any Java program and deletes anything that doesn’t make sense.
(e) When all references to an object are gone the memory used by the object is not reclaimed.

A) c

12) The concept of multiple inheritances is implemented in Java by

I. Extending two or more classes.
II. Extending one class and implementing one or more interfaces.
III. Implementing two or more interfaces.

(a) Only (II) (b) (I) and (II) (c) (II) and (III)
(d) Only (I) (e) Only (III).

A) c

13) In Java, declaring a class abstract is useful

(a) To prevent developers from further extending the class
(b) When it doesn’t make sense to have objects of that class
(c) When default implementations of some methods are not desirable
(d) To force developers to extend the class not to use its capabilities
(e) When it makes sense to have objects of that class.

A) b

14) What is the error in the following class definitions?

Abstract class xy
{
abstract sum (int x, int y) { }
}

(a) Class header is not defined properly.
(b) Constructor is not defined.
(c) Method is not defined properly
(d) Method is defined properly
(e) No error.

A) c

15) Which of these field declarations are legal within the body of an interface?

(a) Private final static int answer = 42 (b) public static int answer=42
(c) final static answer =42 (d) int answer
(e) No error.

A) b

16) A package is a collection of

(a) Classes (b) Interfaces (c) Editing tools
(d) Classes and interfaces (e) Editing tools and interfaces.

A) d

17) A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction?

(a) Declare the method with the keyword public
(b) Declare the method with the keyword private
(c) Declare the method with the keyword protected
(d) Do not declare the method with any accessibility modifiers
(e) Declare the method with the keyword public and private.

A) d

18) Basic Java language functions are stored in which of the following java package?

(a) java.lang (b) java.io (c) java.net (d) java.util (e) java.awt

A) a

19) Which of the following is a member of the java.lang package?

(a) List (b) Queue (c) Math (d) Stack (e) Process.

A) b

20) Which of the following has a method names flush( )?

(a) Input stream (b) Output Stream
(c) Reader stream (d) Input reader stream
(e) Input output stream.

A) b

Core Java Multiple Choice Questions And Answers

Core Java Multiple Choice Questions # 21) What is the fundamental unit of information of writer streams?

(a) Characters (b) Bytes
(c) Files (d) Records (e) Information.

A) a

Core Java Multiple Choice Questions # 22) File class is included in which package?

(a) java.io package (b) java.lang package
(c) java.awt package (d) java.net.package
(e) java.util.package.

A) a

Core Java Multiple Choice Questions # 23) Given the code

String s1 = ” yes” ;
String s2 = ” yes ” ;
String s3 = new String ( s1);

Which of the following would equate to true?

(a) s1 == s2 (b) s1 = s2 (c) s3 == s1 (d) s3=s1 (e) s1!=s2.

A) a

Core Java Multiple Choice Questions # 24) URL stands for

(a) Universal reader locator (b) Universal reform loader
(c) Uniform resource loader (d) Uniform resource locator
(e) Uniform reader locator.

A) d

Core Java Multiple Choice Questions # 25) What is the sequence of major events in the life of an applet?

(a) init, start, stop, destroy (b) start, init , stop , destroy
(c) init, start , destroy, stop (d) init, start, destroy
(e) destroy, start, init, stop.

A) a

Core Java Multiple Choice Questions # 26) Which of the following is true in regard to applet execution?

(a) Applets loaded from the same computer where they are executing have the same restrictions as applets loaded from the network.
(b) Applets loaded and executing locally have none of the restrictions faced by applets that get loaded from the network.
(c) Applets loaded and executing locally have some restrictions faced by applets that get loaded from the network.
(d) Applets cant react to user input and change dynamically
(e) Applets can be run independently.

A) b

Core Java Multiple Choice Questions # 27) What is the return type of the method getID() defined in AWTEvent class

(a) Int (b) long (c) Object (d) Component (e) float.

A) a

Core Java Multiple Choice Questions # 28) Which of the following events will cause a thread to die?

(a) The method sleep( ) is called
(b) The method wait( ) is called
(c) Execution of the start( ) method ends
(d) Execution of the run( ) method ends
(e) Execution of the run() method is called.

A) d

Core Java Multiple Choice Questions # 29) What will be the result of the expression 13 & 25?

(a) 38 (b) 25 (c) 9 (d) 12 (e) 21.

A) c

Core Java Multiple Choice Questions # 30) Which of the following statements are true regarding the finalize( ) method?

(a) The finalize ( ) method must be declared with protected accessibility
(b) The compiler will fail to compile the code that explicitly tries to call the finalize( ) method
(c) The body of the finalize ( ) method can only access other objects that are eligible for garbage collection
(d) The finalize ( ) method can be overloaded
(e) The finalize() method cant be overloaded.

A) d

Core Java Objective Questions And Answers

Core Java Multiple Choice Questions # 31) Which one of these is a valid method declaration?

(a)
void method1
(b)
void method2()
(c)
void method3(void)
(d)
method4()
(e)
methods(void).

A) b

Core Java Multiple Choice Questions # 32) Given a class named Book, which one of these is a valid constructor declaration for the class?

(a)
Book(Book b) { }
(b)
Book Book() { }
(c)
private final Book() { }
(d)
void Book() { }
(e)
abstract Book() { }.

A) a

Core Java Multiple Choice Questions # 33) What will be the result of attempting to compile the following program?

public class MyClass {
long var;
public void MyClass(long param) { var = param; } //(1)
public static void main(String[] args) {
MyClass a,b;
a = new MyClass(); //(2)
b = new MyClass(5); //(3)
}
}

(a)
A compilation ERROR will occur at (1), since constructors cannot specify a return value
(b)
A compilation error will occur at (2), since the class does not have a default constructor
(c)
A compilation error will occur at (3), since the class does not have a constructor which takes one argument of type int
(d)
The program will compile correctly
(e)
The program will compile and execute correctly.

A) c

Core Java Multiple Choice Questions # 34) Given the following class, which of these is valid way of referring to the class from outside of the package net.basemaster?

package net.basemaster;
public class Base {
// . . .
}
Select the correct answer.

(a)
By simply referring to the class as Base
(b)
By simply referring to the class as basemaster.Base
(c)
By simply referring to the class as net.basemaster.Base
(d)
By simply referring to the class as net.Base
(e)
By importing with net.* and referring to the class as basemaster.Base.

A) c

Core Java Multiple Choice Questions # 35) Which one of the following class definitions is a valid definition of a class that cannot be instantiated?

(a)
class Ghost
{
abstract void haunt();
}

(b)
abstract class Ghost
{
void haunt();
}

(c)
abstract class Ghost
{
void haunt() { };
}

(d)
abstract Ghost
{
abstract void haunt();
}

(e)
static class Ghost
{
abstract haunt();
}

A) c

Core Java MCQ Questions With Answers

36) Which one of the following class definitions is a valid definition of a class that cannot be extended?

(a)
class Link { }
(b)
abstract class Link { }
(c)
native class Link { }
(d)
static class Link { }
(e)
final class Link { }.

A) e

37) Given the following definition of a class, which fields are accessible from outside the package com.corporation.project?

package com.corporation.project;
public class MyClass
{
int i;
public int j;
protected int k;
private int l;
}
Select the correct answer.

(a)
Field i is accessible in all classes in other packages
(b)
Field j is accessible in all classes in other packages
(c)
Field k is accessible in all classes in other packages
(d)
Field l is accessible in all classes in other packages
(e)
Field l is accessible in subclasses only in other packages.

A) b

38) How restrictive is the default accessibility compared to public, protected, and private accessibility?

(a)
Less restrictive than public
(b)
More restrictive than public, but less restrictive than protected
(c)
More restrictive than protected, but less restrictive than private
(d)
More restrictive than private
(e)
Less restrictive than protected from within a package, and more restrictive than protected from outside a package.

A) c

39) Which statement is true about accessibility of members?

(a)
Private members are always accessible from within the same package
(b)
Private members can only be accessed by code from within the class of the member
(c)
A member with default accessibility can be accessed by any subclass of the class in which it is defined
(d)
Private members cannot be accessed at all
(e)
Package/default accessibility for a member can be declared using the keyword default.

A) b

40) Which of the following is true about the use of modifiers?

(a)
If no accessibility modifier (public, protected, and private) is specified for a member declaration, the member is only accessible for classes in the package of its class and subclasses of its class anywhere
(b)
You cannot specify accessibility of local variables. They are only accessible within the block in which they are declared
(c)
Subclasses of a class must reside in the same package as the class they extend
(d)
Local variables can be declared static
(e)
None of the above.

A) b

Related Java Interview Questions

  1. 60 Java Multiple Choice Questions
  2. Aricent Java Interview Questions
  3. Accenture Java Interview Questions
  4. Advanced Java Interview Questions For 5 8 10 Years Experienced
  5. Core Java Interview Questions For Experienced

OTHER INTERVIEW QUESTIONS

  1. Anaplan Interview Questions And Answers
  2. Tableau Multiple Choice Questions
  3. Python Coding Interview Questions
  4. CSS3 Interview Questions
  5. Linux Administrator Interview Questions
  6. SQL Interview Questions
  7. Hibernate Interview Questions
  8. Kubernetes Interview Questions
  9. Kibana Interview Questions
  10. Nagios Interview Questions
  11. Jenkins Interview Questions
  12. Chef Interview Questions
  13. Puppet Interview Questions
  14. RPA Interview Questions And Answers
  15. Android Interview Questions
  16. Mulesoft Interview Questions
  17. JSON Interview Questions
  18. PeopleSoft HRMS Interview Questions
  19. PeopleSoft Functional Interview Questions
  20. PeopleTools Interview Questions
  21. Peoplesoft Technical Interview Questions
  22. 199 Peoplesoft Interview Questions
  23. 200 Blue Prism Interview Questions
  24. Visualforce Interview Questions
  25. Salesforce Interview Questions
  26. 300 SSIS Interview Questions
  27. PHP Interview Questions And Answers
  28. Alteryx Interview Questions
  29. AWS Cloud Support Interview Questions
  30. Google Kubernetes Engine Interview Questions
  31. AWS Devops Interview Questions

60 Java Multiple Choice Questions And Answers 2018

Java Multiple Choice Questions And Answers 2018. Here Coding compiler sharing a list of 60 core java and advanced java multiple choice questions and answers for freshers and experienced. These java multiple choice interview questions asked in various java interview exams. We hope that this list of java mcq questions will help you to crack your next java mcq online test. All the best for your future and happy java learning.

 Java Multiple Choice Questions

1) The default value of a static integer variable of a class in Java is,

(a) 0 (b) 1 (c) Garbage value (d) Null (e) -1.

A) a

2) What will be printed as the output of the following program?

public class testincr
{
public static void main(String args[])
{
int i = 0;
i = i++ + i;
System.out.println(“I = ” +i);
}
}

(a) I = 0 (b) I = 1 (c) I = 2 (d) I = 3 (e) Compile-time Error.

A) b

3) Multiple inheritance means,

(a) one class inheriting from more super classes
(b) more classes inheriting from one super class
(c) more classes inheriting from more super classes
(d) None of the above
(e) (a) and (b) above.

A) a

4) Which statement is not true in java language?

(a) A public member of a class can be accessed in all the packages.
(b) A private member of a class cannot be accessed by the methods of the same class.
(c) A private member of a class cannot be accessed from its derived class.
(d) A protected member of a class can be accessed from its derived class.
(e) None of the above.

A) b

5) To prevent any method from overriding, we declare the method as,

(a) static (b) const (c) final (d) abstract (e) none of the above.

A) c

6) Which one of the following is not true?

(a) A class containing abstract methods is called an abstract class.
(b) Abstract methods should be implemented in the derived class.
(c) An abstract class cannot have non-abstract methods.
(d) A class must be qualified as ‘abstract’ class, if it contains one abstract method.
(e) None of the above.

A) c

7) The fields in an interface are implicitly specified as,

(a) static only (b) protected (c) private
(d) both static and final (e) none of the above.

d

8) What is the output of the following program:

public class testmeth
{
static int i = 1;
public static void main(String args[])
{
System.out.println(i+” , “);
m(i);
System.out.println(i);
}
public void m(int i)
{
i += 2;
}
}

(a) 1 , 3 (b) 3 , 1 (c) 1 , 1 (d) 1 , 0 (e) none of the above.

A) c

9) Which of the following is not true?

(a) An interface can extend another interface.
(b) A class which is implementing an interface must implement all the methods of the interface.
(c) An interface can implement another interface.
(d) An interface is a solution for multiple inheritance in java.
(e) None of the above.

A) c

10) Which of the following is true?

(a) A finally block is executed before the catch block but after the try block.
(b) A finally block is executed, only after the catch block is executed.
(c) A finally block is executed whether an exception is thrown or not.
(d) A finally block is executed, only if an exception occurs.
(e) None of the above.

A) c

Java Multiple Choice Questions And Answers

11) Among these expressions, which is(are) of type String?

(a) “0” (b) “ab” + “cd”
(c) ‘0’
(d) Both (A) and (B) above (e) (A), (B) and (C) above.

A) d

12) Consider the following code fragment
Rectangle r1 = new Rectangle();
r1.setColor(Color.blue);
Rectangle r2 = r1;
r2.setColor(Color.red);

After the above piece of code is executed, what are the colors of r1 and
r2 (in this order)?

(a) Color.blue
Color.red
(b) Color.blue
Color.blue
(c) Color.red
Color.red
(d) Color.red
Color.blue
(e) None of the above.

A) c

13) What is the type and value of the following expression? (Notice the integer division)
-4 + 1/2 + 2*-3 + 5.0

(a) int -5 (b) double -4.5
(c) int -4
(d) double -5.0 (e) None of the above.

A) d

14) What is printed by the following statement?
System.out.print(“Hello,\nworld!”);

(a) Hello, \nworld! (b) Hello, world!
(c)
(d) “Hello, \nworld!” (e) None of the above.

A) c

15) Consider the two methods (within the same class)
public static int foo(int a, String s)
{
s = “Yellow”;
a=a+2;
return a;
}
public static void bar()
{
int a=3;
String s = “Blue”;
a = foo(a,s);
System.out.println(“a=”+a+” s=”+s);
}
public static void main(String args[])
{
bar();
}

What is printed on execution of these methods?

(a) a = 3 s = Blue (b) a = 5 s = Yellow (c) a = 3 s = Yellow
(d) a = 5 s = Blue (e) none of the above.

A) d

16) Which of the following variable declaration would NOT compile in a java program?

(a) int var; (b) int VAR; (c) int var1; (d) int var_1; (e) int 1_var;.

A) e

17) Consider the following class definition:

public class MyClass
{
private int value;
public void setValue(int i){ / code / }
// Other methods…
}

The method setValue assigns the value of i to the instance field value. What could you write for the implementation of setValue?

(a) value = i; (b) this.value = i; (c) value == i;
(d) Both (A) and (B) and above (e) (A), (B) and (C) above.

A) d

18) Which of the following is TRUE?

(a) In java, an instance field declared public generates a compilation error.
(b) int is the name of a class available in the package java.lang
(c) Instance variable names may only contain letters and digits.
(d) A class has always a constructor (possibly automatically supplied by the java compiler).
(e) The more comments in a program, the faster the program runs.

A) d

19) A constructor

(a) Must have the same name as the class it is declared within.
(b) Is used to create objects.
(c) May be declared private
(d) Both (A) and (B) above
(e) (a), (b) and (c) above.

A) e

20) Consider,

public class MyClass
{
public MyClass(){/code/}
// more code…
}

To instantiate MyClass, you would write?

(a) MyClass mc = new MyClass();
(b) MyClass mc = MyClass();
(c) MyClass mc = MyClass;
(d) MyClass mc = new MyClass;
(e) The constructor of MyClass should be defined as, public void MyClass(){/code/}.

A) a

Java Programming Multiple Choice Questions

Java Multiple Choice Questions 21) What is byte code in the context of Java?

(a) The type of code generated by a Java compiler.
(b) The type of code generated by a Java Virtual Machine.
(c) It is another name for a Java source file.
(d) It is the code written within the instance methods of a class.
(e) It is another name for comments written within a program.

A) a

Java Multiple Choice Questions 22) What is garbage collection in the context of Java?

(a) The operating system periodically deletes all the java files available on the system.
(b) Any package imported in a program and not used is automatically deleted.
(c) When all references to an object are gone, the memory used by the object is automatically reclaimed.
(d) The JVM checks the output of any Java program and deletes anything that doesn’t make sense.
(e) Janitors working for Sun Micro Systems are required to throw away any Microsoft documentation found in the employees’ offices.

A) c

Java Multiple Choice Questions 23) You read the following statement in a Java program that compiles and executes.
submarine.dive(depth);

What can you say for sure?

(a) depth must be an int
(b) dive must be a method.
(c) dive must be the name of an instance field.
(d) submarine must be the name of a class
(e) submarine must be a method.

A) b

Java Multiple Choice Questions 24) The java run time system automatically calls this method while garbage collection.

(a) finalizer() (b) finalize() (c) finally()
(d) finalized() (e) none of the above.

A) b

Java Multiple Choice Questions 25) The correct order of the declarations in a Java program is,

(a) Package declaration, import statement, class declaration
(b) Import statement, package declaration, class declaration
(c) Import statement, class declaration, package declaration
(d) Class declaration, import statement, package declaration
(e) Class declaration, package declaration, import statement.

A) a

Java Multiple Choice Questions 26) An overloaded method consists of,

(a) The same method name with different types of parameters
(b) The same method name with different number of parameters
(c) The same method name and same number and type of parameters with different return type
(d) Both (a) and (b) above
(e) (a), (b) and (c) above.

A) d

Java Multiple Choice Questions 27) A protected member can be accessed in,

(a) a subclass of the same package (b) a non-subclass of the same package
(c) a non-subclass of different package (d) a subclass of different package
(e) the same class.

Which is the false option?

A) c

Java Multiple Choice Questions 28) What is the output of the following code:

class eq
{
public static void main(String args[])
{
String s1 = “Hello”;
String s2 = new String(s1);
System.out.println(s1==s2);
}
}

(a) true (b) false (c) 0 (d) 1 (e) Hello.

A) b

Java Multiple Choice Questions 29) All exception types are subclasses of the built-in class

(a) Exception (b) RuntimeException (c) Error
(d) Throwable (e) None of the above.

A) d

Java Multiple Choice Questions 30) When an overridden method is called from within a subclass, it will always refer to the version of that method defined by the

(a) Super class
(b) Subclass
(c) Compiler will choose randomly
(d) Interpreter will choose randomly
(e) None of the abvove.

A) b

Java Multiple Choice Questions With Answers

Java Multiple Choice Questions 31) Mark the incorrect statement from the following:

(a) Java is a fully object oriented language with strong support for proper software engineering techniques
(b) In java it is not easy to write C-like so called procedural programs
(c) In java language objects have to be manipulated
(d) In java language error processing is built into the language
(e) Java is not a language for internet programming.

A) d

Java Multiple Choice Questions 32) In java, objects are passed as

(a) Copy of that object (b) Method called call by value
(c) Memory address (d) Constructor
(e) Default constructor.

A) c

Java Multiple Choice Questions 33) Which of the following is not a component of Java Integrated Development Environment (IDE)?

(a) Net Beans (b) Borland’s Jbuilder
(c) Symantec’s Visual Café (d) Microsoft Visual Fox Pro
(e) Microsoft Visual J++.

A) c

Java Multiple Choice Questions 34) Identify, from among the following, the incorrect variable name(s).

(a) _theButton (b) $reallyBigNumber
(c) 2ndName (d) CurrentWeatherStateofplanet
(e) my2ndFont.

A) c

Java Multiple Choice Questions 35) Use the following declaration and initialization to evaluate the Java expressions

int a = 2, b = 3, c = 4, d = 5;
float k = 4.3f;

System.out.println( – -b * a + c *d – -);

(a) 21 (b) 24 (c) 28 (d) 26 (e) 22.

A) b

Java Multiple Choice Questions 36) Use the following declaration and initialization to evaluate the Java expressions

int a = 2, b = 3, c = 4, d = 5;
float k = 4.3f;

System.out.println(a++);

(a) 3 (b) 2 (c) 4 (d) 10 (e) Synatax error.

A) b

Java Multiple Choice Questions 37) Use the following declaration and initialization to evaluate the Java expressions

int a = 2, b = 3, c = 4, d = 5;
float k = 4.3f;

System.out.println (-2U * ( g – k ) +c);

(a) 6 (b) 3 (c) 2 (d) 1 (e) Syntax error.

A) e

Java Multiple Choice Questions 38) Use the following declaration and initialization to evaluate the Java expressions

int a = 2, b = 3, c = 4, d = 5;
float k = 4.3f;

System.out.println (c=c++);

(a) 2 (b) 4 (c) 5 (d) 8 (e) Syntax error.

A) b

Java Multiple Choice Questions 39) Consider the following Java program :

class IfStatement{
public static void main(String args[])
{
int a=2, b=3;
if (a==3)
if (b==3)
System.out.println(“===============”);
else
System.out.println(“#################”);
System.out.println(“&&&&&&&&&&&”);
}
}

Which of the following will the output be?

(a) ===============
(b) #################
&&&&&&&&&
(c) &&&&&&&&&&&
(d) ===============
#################
&&&&&&&&&&
(e) ################.

A) c

Java Multiple Choice Questions 40) An applet cannot be viewed using

(a) Netscape navigator
(b) Microsoft Internet Explorer
(c) Sun’ Hot Java Browser
(d) Applet viewer tool which comes, with the Java Development Kit.
(e) Jbuilder.

A) d

Use the following Java program for answering question 11 and 12
class test{
void meth(int i, int j)
{
i *= 2;
i /= 2;
}
}

class argumentPassing
{
public static void main(String args[])
{
test ob = new test();
int a = 15, b = 20;

System.out.println(“a and b before call :”+ a +” ” + b);
ob.meth(a,b);
System.out.println(“a and b after call : “+ a + ” ” +b);
}

Core Java Multiple Choice Questions With Answers

41) What would the output be of the above Program – III before and after it is called?

(a) and b before call : 15 20 a and b after call : 30 10
(b) a and b before call : 5 2 a and b after call : 15 20
(c) a and b before call : 15 20 a and b after call : 15 20
(d) a and b before call : 30 10 a and b after call : 15 20
(e) a and b before call : 15 20 a and b after call :

A) c

42) What would the argument passing method be which is used by the above Program – III?

(a) Call by value (b) Call by reference
(c) Call by java.lang class (d) Call by byte code
(e) Call by compiler.

A) a

43) Consider the following program:

class prob1{
int puzzel(int n){

int result;

if (n==1)
return 1;
result = puzzel(n-1) * n;
return result;
}
}

class prob2{

public static void main(String args[])

{

prob1 f = new prob1();

System.out.println(” puzzel of 6 is = ” + f.puzzel(6));

}
}

Which of the following will be the output of the above program?

(a) 6 (b) 120 (c) 30 (d) 720 (e) 12.

A) d

44) The blank space in the following sentence has to be correctly filled :

Members of a class specified as ……………….. are accessible only to methods of that class.

(a) Protected (b) Final (c) Public (d) Private (e) Static.

A) d

45) Java compiler javac translates Java source code into ………………………

(a) Assembler language (b) Byte code
(c) Bit code (d) Machine code
(e) Platform dependent code.

A) b

46) ……………….. are used to document a program and improve its readability.

(a) System cells (b) Keywords (c) Comments (d) Control structures (e) Blocks.

A) c

47) In Java, a character constant’s value is its integer value in the ………………………character set.

(a) EBCDIC (b) Unicode (c) ASCII (d) Binary (e) BCD.

A) b

48) In Java, a try block should immediately be followed by one or more ……………….. blocks.

(a) Throw (b) Run (c) Exit (d) Catch (e) Error.

A) d

49) An abstract data type typically comprises a …………… and a set of ……………… respectively.

(a) Data representation, classes (b) Database, operations
(c) Data representation, objects (d) Control structure, operations
(e) Data representation, operations.

A) e

50) In object-oriented programming, the process by which one object acquires the properties of another object is called

(a) Encapsulation (b) Polymorphism (c) Overloading
(d) Inheritance (e) Overriding.

A) d

Advanced Java Multiple Choice Questions Ans Answers

51) Re-implementing an inherited method in a sub class to perform a different task from the parent class is called

(a) Binding (b) Transferring (c) Hiding (d) Coupling (e) extending.

A) e

52) In a class definition, the special method provided to be called to create an instance of that class is known as a/an

(a) Interpreter (b) Destructor (c) Constructor (d) Object (e) Compiler.

A) c

53) Consider the following statements about Java packages:

I. Packages don’t provide a mechanism to partition all class names into more manageable chunks.
II. Packages provide a visibility control mechanism.
III. One of the important properties of a package is that all classes defined inside a package is accessible by code outside that package.
IV. The .class files for classes declared to be part of a package can be stored in multiple directories.

Which of them is correct?
(a) Only (I) above (b) Only (II) above
(c) Only (III) above (d) Only (IV) above
(e) All (I), (II), (III) and (IV) above are wrong.

A) b

54) Consider the following statements:

I. A class can be declared as both abstract and final.
II. A class declared as final can be extended by defining a sub-class.
III. Resolving calls to methods dynamically at run-time is called late binding.
IV. The class Object defined by Java need not be a super class of all other classes.

Identify the correct statement from the following:

(a) Both (I) and (II) above (b) Both (III) and (IV) above
(c) Both (I) and (III) above (d) Both (II) and (IV) above
(e) Only (III) above.

A) e

55) Identify, from among the following, the incorrect descriptions related to Java :

(a) Java Virtual Machine translates byte code into its own system’s machine language and runs the resulting machine code
(b) The arithmetic operations *, /, %, + and – have the same level of precedence
(c) Comments do not cause any action to be performed during the program execution
(d) All variables must be given a type when they are declared
(e) Java variable names are case-sensitive.

A) b

56) Consider the following statement(s) about Java:

I. All white-space characters (blanks) are ignored by the compiler.
II. Java keywords can be used as variable names.
III. An identifier does not begin with a digit and does not contain any spaces.
IV. The execution of Java applications begins at method main.

Which of them is correct?

(a) Both (I) and (III) above (b) Both (II) and (IV) above
(c) Both (I) and (II) above (d) (III) and (IV) above
(e) All (I), (II), (III) and (IV) above.

A) d

57) Consider the following data types in Java :

I. Int II. Boolean III. Double IV. String V. Array.

Which of them are simple data types?

(a) Both (I) and (II) above (b) (I), (II), (III) and (IV) above
(c) (I), (II) and (III) above (d) (II) and (III) above
(e) All (I), (II), (III), (IV) and (V) above.

A) c

58) For what values respectively of the variables gender and age would the Java expression gender == 1 && age >= 65 become true?

(a) gender = 1, age = 60 (b) gender = 1, age = 50
(c) gender = 1, age = 65 (d) gender = 0, age = 70
(e) gender = 0, age = 55.

A) c

59) Consider the following Java program :

public class Compute {

public static void main (string args [ ])
{
int result, x ;
x = 1 ;
result = 0;
while (x < = 10) {
if (x%2 == 0) result + = x ;
+ + x ;
}
System.out.println(result) ;
}
}

Which of the following will be the output of the above program?

(a) 55 (b) 30 (c) 25 (d) 35 (e) 45.

A) b

60) Which of the following statements about Java Threads is correct?

(a) Java threads don’t allow parts of a program to be executed in parallel
(b) Java is a single-threaded language
(c) Java’s garbage collector runs as a high priority thread
(d) Ready, running and sleeping are three states that a thread can be in during its life cycle
(e) Every java application is not multithreaded.

A) d

Related Java Interview Questions

  1. Aricent Java Interview Questions
  2. Accenture Java Interview Questions
  3. Advanced Java Interview Questions For 5 8 10 Years Experienced
  4. Core Java Interview Questions For Experienced

OTHER INTERVIEW QUESTIONS

  1. Tableau Multiple Choice Questions
  2. Python Coding Interview Questions
  3. CSS3 Interview Questions
  4. Linux Administrator Interview Questions
  5. SQL Interview Questions
  6. Hibernate Interview Questions
  7. Kubernetes Interview Questions
  8. Kibana Interview Questions
  9. Nagios Interview Questions
  10. Jenkins Interview Questions
  11. Chef Interview Questions
  12. Puppet Interview Questions
  13. RPA Interview Questions And Answers
  14. Android Interview Questions
  15. Mulesoft Interview Questions
  16. JSON Interview Questions
  17. PeopleSoft HRMS Interview Questions
  18. PeopleSoft Functional Interview Questions
  19. PeopleTools Interview Questions
  20. Peoplesoft Technical Interview Questions
  21. 199 Peoplesoft Interview Questions
  22. 200 Blue Prism Interview Questions
  23. Visualforce Interview Questions
  24. Salesforce Interview Questions
  25. 300 SSIS Interview Questions
  26. PHP Interview Questions And Answers
  27. Alteryx Interview Questions
  28. AWS Cloud Support Interview Questions
  29. Google Kubernetes Engine Interview Questions
  30. AWS Devops Interview Questions

Hibernate Interview Questions And Answers For Experienced

75 Hibernate Interview Questions And Answers For Experienced 2018. Here in this post coding compiler presenting a list of 75 advanced hibernate interview questions for freshers, 1 year experience, 2 years experience, 3 year experience, 4 year experience, 5 year experience.

Hibernate Interview Questions

Hibernate Interview Questions For Freshers

Question # 1 What is hibernate in java?

Answer #  Hibernate ORM (Hibernate in short) is an object-relational mapping tool for the Java programming language. It provides a framework for mapping an object-oriented domain model to a relational database. Hibernate also provides data query and retrieval facilities.

Question # 2 Is hibernate better than JDBC?

Answer # JDBC will always give better performance as compared to Hibernate for most of the database vendors. … The choice of hibernate over jdbc and sql queries is not because of the performance but because of reasons mainly object persistence and database independence in terms of not writing database specific queries.

Question # 3 Why do we need hibernate in Java?

Answer # So with JDBC, mapping between Java objects and database tables is done manually. Hibernate reduces lines of code by maintaining object-table mapping itself and returns result to application in form of Java objects. Hibernate, with Transparent Persistence, cache is set to application work space.

Question # 4 What is the use of ORM in Java?

Answer # ORM allows you to use java objects as representation of a relational database. It maps the two concepts (object-oriented and relational) Hibernate is an ORM framework – you describe how your objects are represented in your database, and hibernate handles the conversion.

Question # 5 What is the difference between JPA and Hibernate?

Answer # JPA is the interface, Hibernate is one implementation of that interface. JPA is a specification for accessing, persisting and managing the data between Java objects and the relational database. As the definition says its API, it is only the specification. Hibernate is a JPA provider.

Hibernate Interview Questions And Answers

Question # 6 What is the use of Session in hibernate?

Answer # The main runtime interface between a Java application and Hibernate. This is the central API class abstracting the notion of a persistence service. The lifecycle of a Session is bounded by the beginning and end of a logical transaction. (Long transactions might span several database transactions.)

Question # 7 What is the architecture of hibernate?

Answer # Hibernate makes use of the database and configuration data to provide persistence services (and persistent objects) to the application.

Question # 8 What is ORM hibernate?

Answer # Hibernate ORM (Hibernate in short) is an object-relational mapping tool for the Java programming language. It provides a framework for mapping an object-oriented domain model to a relational database.

Question # 9 Can we use only JPA without hibernate?

Answer # You have to specify the persistence provider(Hibernate,EclipseLink) in order to use the JPA implementation. The persistence providers have the implementaion classes for JPA specifications. You can’t just use JPA, cause it is an API =), but there are plenty JPA implementations: EclipseLink.

Question # 10 What are the fetching strategies supported by hibernate?

Answer # Fetch strategies can be declared in the O/R mapping metadata, or over-ridden by a particular HQL or Criteria query. Hibernate defines the following fetching strategies:

  1. Join fetching
  2. Select fetching
  3. Subselect fetching
  4. Batch fetching
  5. Immediate fetching
  6. Lazy collection fetching
  7. “Extra-lazy” collection fetching
  8. Proxy fetching
  9. “No-proxy” fetching
  10. Lazy attribute fetching

Hibernate Interview Questions For Experienced

Question # 11 What is a polymorphic association?

Answer # Polymorphic association is a term used in discussions of Object-Relational Mapping with respect to the problem of representing in the relational database domain, a relationship from one class to multiple classes. In statically typed languages such as Java these multiple classes are subclasses of the same superclass.

Question # 12 What is the difference between session and Sessionfactory in hibernate?

Answer # SessionFactory is Hibernate’s concept of a single datastore and is threadsafe so that many threads can access it concurrently and request for sessions and immutable cache of compiled mappings for a single database. Sessions are opened by a SessionFactory and then are closed when all work is complete.

Question # 13 What is the difference between load and get method in hibernate?

Answer # Session.load(): It will always return a “proxy” (Hibernate term) without hitting the database. In Hibernate, proxy is an object with the given identifier value, its properties are not initialized yet, it just look like a temporary fake object. If no row found , it will throws an ObjectNotFoundException.

Question # 14 Is hibernate Sessionfactory Singleton?

Answer # SessionFactory is also thread safe so only one thread can execute at a time its code. The instance of sessionFactory is heavyweighted because it contains connection, hibernate configuration, mapping files, location path so if you create number of instance of sessionFactory then your code becomes very heavy.

Question # 15 What are the configuration files in hibernate?

Answer # Hibernate also requires a set of configuration settings related to database and other related parameters. All such information is usually supplied as a standard Java properties file called hibernate.properties, or as an XML file named hibernate.cfg.xml.

Hibernate Interview Questions And Answers For Experienced

Questions # 16 What is the use of dialect in hibernate?

Answer # Dialect means “the variant of a language”. Hibernate, as we know, is database agnostic. It can work with different databases. However, databases have proprietary extensions/native SQL variations, and set/sub-set of SQL standard implementations. Therefore at some point hibernate has to use database specific SQL.

Question # 17 What is the use of Show_sql in hibernate?

Answer # Hibernate has build-in a function to enable the logging of all the generated SQL statements to the console. You can enable it by add a “show_sql” property in the Hibernate configuration file “ hibernate.cfg.xml “. This function is good for basic troubleshooting, and to see what’s Hibernate is doing behind.

Question # 18 What is hibernate proxy and how it helps in lazy loading?

Answer # A proxy is a subclass implemented at runtime. Hibernate creates a proxy (a subclass of the class being fetched) instead of querying the database directly, and this proxy will load the “real” object from the database whenever one of its methods is called.

Question # 19 Is session is thread safe in hibernate?

Answer # SessionFactory is Hibernates concept of a single datastore and is threadsafe so that many threads can access it concurrently and request for sessions and immutable cache of compiled mappings for a single database. Why to make session object thread safe if we already have a SessionFactory(immutable) object.

Hibernate Interview Questions And Answers For 2 Years Experience

Question # 20 What is the use of configuration in hibernate?

Answer # The org.hibernate.cfg.Configuration is used to build an immutable org.hibernate.SessionFactory . The mappings are compiled from various XML mapping files. A org.hibernate.cfg.Configuration also allows you to specify configuration properties.

Question # 21 What is criteria in hibernate?

Answer # In Hibernate, the Criteria API helps us build criteria query objects dynamically. Criteria is a another technique of data retrieval apart from HQL and native SQL queries. The primary advantage of the Criteria API is that it is intuitively designed to manipulate data without using any hard-coded SQL statements.

Question # 22 What is the difference between lazy and eager loading in hibernate?

Answer # All data is fetched when eager marked data in the object when session is connected. However, in case of lazy loading strategy, lazy loading marked object does not retrieve data if session is disconnected (after session.close() statement). All that can be made by hibernate proxy.

Question # 23 Is Sessionfactory immutable?

Answer # The internal state of a SessionFactory is immutable. Most problems with concurrency occur due to sharing of objects with mutable state. Once the object is immutable, its internal state is setted on creation and cannot be changed. So many threads can access it concurrently and request for sessions.

Question # 24 Is Hibernate configuration file mandatory?

Answer # Basically you are setting all the required properties via your properties object so there is no real need to tell Hibernate to look for a hibernate.cfg.xml file which is exactly what the configure() method does. No, it’s not mandatory to use hibernate.cfg.xml. Just don’t use .configure().

Question # 25 What is meant by annotation in hibernate?

Answer # Hibernate annotations are the newest way to define mappings without the use of XML file. You can use annotations in addition to or as a replacement of XML mapping metadata. Hibernate Annotations is the powerful way to provide the metadata for the Object and Relational Table mapping.

Hibernate Interview Questions And Answers For Experienced In Java

Question # 26 What does hibernate.hbm2ddl.auto create means?

Answer # hibernate.hbm2ddl.auto. Automatically validates or exports schema DDL to the database when the SessionFactory is created. With create-drop , the database schema will be dropped when the SessionFactory is closed explicitly.

Question # 27 What is the meaning of persistence in hibernate?

Answer # When a POJO instance is in session scope, it is said to be persistent i.e hibernate detects any changes made to that object and synchronizes it with database when we close or flush the session. And about hibernate.properties and XML Mapping.

Question # 28 How does Hibernate proxy work?

Answer # When a method is invoked on the object, Hibernate will fetch the data from the column and populate the object. This is the proxy mechanism. To add this new behavior (the loading of the data when a method is invoked), Hibernate will create a dynamic subclass of Person using CGLib and add the desired functionality.

Question # 29 What is first level cache in hibernate?

Answer # First level cache is associated with “session” object. The scope of cache objects is of session. First level cache is enabled by default and you can not disable it. When we query an entity first time, it is retrieved from database and stored in first level cache associated with hibernate session.

Question # 30 What is the use of Session in hibernate?

Answer # The main runtime interface between a Java application and Hibernate. This is the central API class abstracting the notion of a persistence service. The lifecycle of a Session is bounded by the beginning and end of a logical transaction. (Long transactions might span several database transactions.)

Hibernate Interview Questions And Answers For 3 Years Experience

Question # 31 What is lazy fetching in Hibernate?

Answer # Lazy fetching decides whether to load child objects while loading the Parent Object. You need to do this setting respective hibernate mapping file of the parent class. Lazy = true (means not to load child) By default the lazy loading of the child objects is true.

Question # 32 What is an SQL dialect?

Answer # SQL Dialect. The SQL dialect, derived from the Structured Query Language, uses human-readable expressions to define query statements. Use a SQL query statement with the following ADSI search interfaces: The ActiveX Data Object (ADO) interfaces, which are Automation interfaces that use OLE DB.

Question # 33 What is in HQL?

Answer # Hibernate Query Language (HQL) is an object-oriented query language, similar to SQL, but instead of operating on tables and columns, HQL works with persistent objects and their properties. HQL queries are translated by Hibernate into conventional SQL queries, which in turns perform action on database.

Question # 34 What is the use of projection in hibernate?

Answer # To put it simple, Hibernate Projections are used in order to query only a subset of the attributes of an entity or group of entities you’re querying with Criteria. You can also use Projections to specify distinct clauses and aggregate functions like max , sum and so on. Like modifying the select clause in an SQL query.

Question # 35 What is Lazyinitializationexception in hibernate?

Answer # Indicates access to unfetched data outside of a session context. For example, when an uninitialized proxy or collection is accessed after the session was closed.

Question # 36 What are the different cascade types in hibernate?

Answer #
JPA EntityManager action  – JPA CascadeType  –  Hibernate native Session action – Hibernate native CascadeTypedetach(entity)       DETACH  evict(entity)   DETACH or EVICT merge(entity)                     MERGE               merge(entity)              MERGEpersist(entity)                            PERSIST               persist(entity)            PERSISTrefresh(entity)                            REFRESH               refresh(entity)          REFRESHremove(entity)                            REMOVE               delete(entity)            REMOVE or DELETE                                                               saveOrUpdate(entity)                       SAVE_UPDATE                                                           replicate(entity, replicationMode)      REPLICATElock(entity, lockModeType)     buildLockRequest(entity, lockOptions)  LOCK

Question # 37 What is the use of Show_sql in hibernate?

Answer # Hibernate has build-in a function to enable the logging of all the generated SQL statements to the console. You can enable it by add a “show_sql” property in the Hibernate configuration file “ hibernate.cfg.xml “.

This function is good for basic troubleshooting, and to see what’s Hibernate is doing behind.

Question # 38 What is hbm2ddl in hibernate?

Answer # hibernate.hbm2ddl.auto Automatically validates or exports schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly.

Question # 39 What is the use of dialect in hibernate?

Answer # Dialect means “the variant of a language”. Hibernate, as we know, is database agnostic. It can work with different databases. However, databases have proprietary extensions/native SQL variations, and set/sub-set of SQL standard implementations. Therefore at some point hibernate has to use database specific SQL.

Question # 40 Can I disable first level cache in hibernate?

Answer # The scope of cache objects is of session. Once session is closed, cached objects are gone forever. First level cache is enabled by default and you can not disable it. When we query an entity first time, it is retrieved from database and stored in first level cache associated with hibernate session.

Hibernate Interview Questions And Answers For 4 Years Experience

Question # 41 What is criteria in hibernate?

Answer # In Hibernate, the Criteria API helps us build criteria query objects dynamically. Criteria is a another technique of data retrieval apart from HQL and native SQL queries. The primary advantage of the Criteria API is that it is intuitively designed to manipulate data without using any hard-coded SQL statements.

Question # 42 Which one is faster JDBC or hibernate?

Answer # JDBC will always give better performance as compared to Hibernate for most of the database vendors. The choice of hibernate over jdbc and sql queries is not because of the performance but because of reasons mainly object persistence and database independence in terms of not writing database specific queries.

Question # 43 What is the use of bag in hibernate?

Answer # Hibernate Bag is a java collection that stores elements without caring about the sequencing, but allow duplicate elements in the list. A bag is a random grouping of the objects in the list.

Question # 44 What is the use of Mappedby in hibernate?

Answer # With the mappedBy , you directly tell Hibernate/JPA that one table owns the relationship, and therefore it is stored as a column of that table. Without, the relationship is external and Hibernate/JPA need to create another table to store the relationship.

Question # 45 What is inverse true in hibernate?

Answer # The real meaning is that it defines which side is the parent or the relationship owner for the two entities (parent or child). Hence, inverse=”true” in a Hibernate mapping shows that this class (the one with this XML definition) is the relationship owner; while the other class is the child.

Question # 46 What is a bidirectional relationship?

Answer # Bidirectional Relationships. In a bidirectional relationship, each entity has a relationship field or property that refers to the other entity. Through the relationship field or property, an entity class’s code can access its related object.

Question # 47 What is the dirty checking in hibernate?

Answer # Hibernate allows dirty checking feature.All persistent objects are monitored by hibernate.it detects which objects have been modified and then calls update statements on all updated objects.the process of updating the changed object is called automatic dirty checking.

Question # 48 What are the important interfaces in hibernate?

Answer #
Session InterfaceSession Factory InterfaceConfiguration InterfaceTransaction InterfaceQuery and Criteria Interface

Question # 49 What is hibernate mapping file?

Answer # The mapping document is an XML document having <hibernate-mapping> as the root element, which contains all the <class> elements. The <class> elements are used to define specific mappings from a Java classes to the database tables.

Question # 50 What is difference between openSession() and getCurrentSession()?

Answer # If you set hibernate.current_session_context_class to thread and then implement something like a servlet filter that opens the session – then you can access that session anywhere else by using the SessionFactory.getCurrentSession().

SessionFactory.openSession() always opens a new session that you have to close once you are done with the operations.

SessionFactory.getCurrentSession() returns a session bound to a context – you don’t need to close this.

Hibernate Interview Questions And Answers For 5 Years Experience

Question # 51 What is difference between Session get() and load() method in Hibernate?

Answer #
Session.load() – It will always return a “proxy” (Hibernate  term) without hitting the database. In Hibernate, proxy is an object  with the given identifier value, its properties are not initialized yet,  it just look like a temporary fake object. If no row found , it will throws an ObjectNotFoundException.

Session.get() – It always hit the database and return the real object, an object that represent the database row, not proxy.If no row found , it return null.

Question # 52 What are different states of an entity bean in Hybernate?

Answer # The Entity bean has three states:
TransientPersistentDetached

Transient: When ever we create a new object of Entity bean then we can say that is in Transient state,At that time any modification in the object state does not effect on database.

Persistent: When ever the Object of entity bean associated with session we can say that is in persistent state, if any change in the object state , then that modification effects in database.

Detached :When ever the object is removed from session then it enters in to detached state.Any modification on detached state object , does not effect in database.

Question # 53 Difference between hibernate session merge() vs update()?

Answer # Hibernate handles persisting any changes to objects in the session when the session is flushed. update can fail if an instance of the object is already in the session. Merge should be used in that case. It merges the changes of the detached object with an object in the session, if it exists.

Question # 54 Difference between save() and saveorupdate() in hibernate?

Answer # The important difference between the org.hibernate.Session class methods, save & saveOrUpdate is, save generates a new identifier and results in an INSERT query, whereas saveOrUpdate does an INSERT or an UPDATE. Save method stores an object into the database.

Question # 55 What is the difference between save() and persist() in hibernate?

Answer # persist() – Hibernate persist is similar to save (with transaction) and it adds the entity object to the persistent context, so any further changes are tracked. If the object properties are changed before the transaction is committed or session is flushed, it will also be saved into database.

persist() also guarantees that it will not execute an INSERT statement if it is called outside of transaction boundaries. This is useful in long-running conversations with an extended Session/persistence context.

save() does not guarantee the same, it returns an identifier, and if an INSERT has to be executed to get the identifier (e.g. “identity” generator, not “sequence”), this INSERT happens immediately, no matter if you are inside or outside of a transaction. This is not good in a long-running conversation with an extended Session/persistence context.

Hibernate Tricky Interview Questions For Experienced

Question # 56 What are the collection types in Hibernate?

Answer # Hibernate collections types are:
java.util.List.java.util.Set.java.util.SortedSet.java.util.Map.java.util.SortedMap.java.util.Collection.or write the implementation of org.hibernate.usertype.UserCollectionType.

Question # 57 How to implement Joins in Hibernate?

Answer # Using HQL we can implement joins in hibernate.
HQL Joins – HQL supports inner join, left outer join, right outer join and full join. For example, select e.name, a.city from Employee e INNER JOIN e.address a . In this query, Employee class should have a variable named address.

Question # 58 What is Named SQL Query?

Answer # A named query is a SQL expression represented as a table. In a named query, you can specify an SQL expression to select rows and columns returned from one or more tables in one or more data sources.

Question # 59 What is Hibernate Criteria API?

Answer # In Hibernate, the Criteria API helps us build criteria query objects dynamically. Criteria is a another technique of data retrieval apart from HQL and native SQL queries. The primary advantage of the Criteria API is that it is intuitively designed to manipulate data without using any hard-coded SQL statements.

Question # 60 What are callback interfaces in hibernate?

Answer # Callback interface for Hibernate code. To be used with HibernateTemplate ‘s execution methods, often as anonymous classes within a method implementation. The typical implementation will call Session.load/find/update to perform some operations on persistent objects.

Hibernate Tough Interview Questions And Answers For Experienced

Question # 61 What is transaction management in hibernate?

Answer # In a non-managed environment, Hibernate is usually responsible for its own database connection pool. The application developer has to manually set transaction boundaries (begin, commit, or rollback database transactions) themselves.

Question # 62 What are the mapping associations used in hibernate?

Answer # There are two mapping associations used in hibernate, they are:
1) One-to-One Association2) Many-to-Many Association

Question # 63 What is Hibernate QBC API?

Answer # Hibernate Query By Criteria (QBC) API is used to create queries by manipulation of criteria objects at runtime.

Question # 64 What is hibernate criteria join?

Answer # Hibernate Criteria JOIN API allows users to perform join operation.
Suppose you have to perform a operation like
SELECT S.*, C.* FROM STUDENT S, CONTACT  C WHERE S.ROLL_NO=C.ID;
Then you can write this statement using Criteria join in a very simple way
Criteria criteria = session.createCriteria(Student.class);criteria.setFetchMode(“Contact”, FetchMode.JOIN);List list = criteria.list();

Question # 65 What is the is the default transaction factory in hibernate?

Answer # JDBCTransactionFactory is the default transaction factory in hibernate.

Hibernate Real Time Interview Questions And Answers For Experienced

Question # 66 What is JMX in Hybernate?

Answer # Java Management Extensions (JMX) is a Java technology that supplies tools for managing and monitoring applications, system objects, devices (such as printers) and service-oriented networks. Those resources are represented by objects called MBeans (for Managed Bean).

Question # 67 How to bind hibernate session factory to JNDI?

Answer # When binding the SessionFactory to JNDI, Hibernate will use the values of hibernate.jndi.url , hibernate.jndi.class to instantiate an initial context.

Question # 68 What are the fetching strategies in hibernate?

Answer # There are four fetching strategies

1. fetch-“join” = Disable the lazy loading, always load all the collections and entities.

2. fetch-“select” (default) = Lazy load all the collections and entities.

3. batch-size=”N” = Fetching up to ‘N’ collections or entities, *Not record*.

4. fetch-“subselect” = Group its collection into a sub select statement.

Question # 69 What are derived properties in hibernate?

Answer # In Hibernate a derived property (also called a calculated property) is a read-only property whose value is calculated at fetch time using SQL expressions.

Question # 70 What is version property in hibernate?

Answer # The <version> property (or @Version annotation) – We know that that Hibernate can provide optimistic locking through a version property on your persistent objects. Furthermore, the version property is automatically managed by Hibernate.

Advanced Hibernate Interview Questions And Answers For Experienced

Question # 71 What does session lock () method do in hibernate?

Answer # The lock() method, with LockOptions.NONE, can be used to associate a detached object to a session and put the object back into a persistence context. On top is Hibernate code to reattach a detached object using a typical update method call. On the bottom is code to reattach a detached object using a lock method call.

Question # 72 What does evict do in hibernate?

Answer # evict() To detach the object from session cache, hibernate provides evict() method. After detaching the object from the session, any change to object will not be persisted. The associated objects will also be detached if the association is mapped with cascade=”evict”.

Question # 73 What is implicit polymorphism in hibernate?

Answer # Implicit polymorphism means if a class or interface is used in HQL, criteria or named queries, hibernate fetches the records from the table mapped to the used class along with all the tables mapped to its subclasses, at any hierarchy level. This is one of the great advantage for using hibernate.

Question # 74 What is table per concrete class in hibernate?

Answer # When we use Table Per Concrete class in hibernate, tables are created per class. So there are no nullable values in the table. Disadvantage of this approach is that duplicate columns are created in the subclass tables.

Question # 75 What is light object mapping in hibernate?

Answer # Light Object Mapping is one of the levels of ORM quality in which all entities are represented as classes and they are mapped manually in the Relational Tables.

The code is hidden from the business logic by implementing specific design patterns. In this Light Object Mapping in Hibernate is one of the valuable levels of ORM quality that approach for successful application which having less number of entities, or for common applications, Metadata and driven data models.

RELATED INTERVIEW QUESTIONS

  1. ASP.NET Interview Questions
  2. PHP Interview Questions
  3. Kubernetes Interview Questions
  4. Docker Interview Questions
  5. CEH Interview Questions
  6. CyberArk Interview Questions
  7. Appian Interview Questions
  8. Drools Interview Questions
  9. Talend Interview Questions
  10. Selenium Interview Questions
  11. Ab Initio Interview Questions
  12. AB Testing Interview Questions
  13. Mobile Application Testing Interview Questions
  14. Pega Interview Questions
  15. UI Developer Interview Questions
  16. Tableau Interview Questions
  17. SAP ABAP Interview Questions
  18. Reactjs Interview Questions
  19. UiPath Interview Questions
  20. Automation Anywhere Interview Questions
  21. RPA Interview Questions
  22. RPA Blue Prism Interview Questions
  23. Ranorex Interview Questions
  24. AWS Interview Questions
  25. SSRS Interview Questions
  26. SQL Interview Questions
  27. Informatica MDM Interview Questions
  28. CyberArk Interview Questions
  29. SAP SD Interview Questions
  30. SAP EWM Interview Questions

21 Aricent Java Interview Questions

Aricent Java Interview Questions. Coding compiler compiled a list of 21 real-time java interview questions for experienced. These advanced java questions will help you to prepare for Aricent job interview.

Aricent Java Interview Questions

Go through these below Aricent java interview questions.

  1. When Abstract Methods Are Used?
  2. What Are Wrapper Classes?
  3. What Do You Mean By Platform Independence?
  4. What Is A Pointer And Does Java Support Pointers?
  5. What Is The Difference Between Creating String As New() And Literal?
  • What Is The Use Of The Finally Block? Is Finally Block In Java Guaranteed To Be Called? When Finally Block Is Not Called?
  • What’s The Difference Between The Methods Sleep() And Wait()?
  • What Is The Difference Between An Interface And An Abstract Class ?
  • Difference Between Final, Finally And Finalize ?

Aricent Real-Time Interview Questions

What Is Struts?

How Is The Mvc Design Pattern Used In Struts Framework?

Who Makes The Struts?

Why It Called Struts?

Do We Need To Pay The Struts If Being Used In Commercial Purpose?

What Are The Core Classes Of Struts?

What Is The Design Role Played By Struts?

What Interface Is Extended By Awt Event Listeners?

What Restrictions Are Placed On Method Overriding?

How Can A Dead Thread Be Restarted?

What Happens If An Exception Is Not Caught?

RELATED INTERVIEW QUESTIONS

  1. Accenture Java Interview Questions
  2. Advanced Java Interview Questions
  3. Core Java Interview Questions
  4. .NET Interview Questions
  5. Ansible Interview Questions
  6. ServiceNow Interview Questions
  7. RPA Interview Questions
  8. Blue Prism Interview Questions
  9. SSIS Interview Questions And Answers
  10. Oracle Performance Tuning Interview Questions
  11. SCCM Interview Questions
  12. ServiceNow Interview Questions
  13. SQL Interview Questions
  14. Docker Interview Questions

53 Accenture Java Interview Questions

Accenture Java Interview Questions. Coding compiler compiled a list of 53 real-time java interview questions for experienced. These java questions will help you to prepare for Accenture job interview.

Accenture Java Interview Questions

Go through these below Accenture java interview questions.

  • Describe A Problem You Faced And How You Deal With It ?
  • How To Read And Write Image From A File ?
  • How Concurrenthashmap Works?
  • Can A Static Block Throw Exception?
  • What Is Difference Between Iterator Access And Index Access?
  • What Is Java Reflection Api?
  • What Is The Difference Between Serializable And Externalizable Interfaces?
  1. What Is An Abstract Method?
  2. What Value Does Read() Return When It Has Reached The End Of A File?
  3. Can A Byte Object Be Cast To A Double Value?
  4. What Is The Difference Between A Static And A Non-static Inner Class?
  5. What Is An Object’s Lock And Which Object’s Have Locks?
  6. What Is The % Operator?
  7. When Can An Object Reference Be Cast To An Interface Reference?
  8. Which Class Is Extended By All Other Classes?
  9. Which Non-unicode Letter Characters May Be Used As The First Character Of An Identifier?

Accenture Java Interview Questions for Experienced

What Restrictions Are Placed On Method Overloading?
What Is Transient Variable?
What Is Collection Api?
What Is Casting?
What Is The Return Type Of A Program’s Main() Method?
If A Variable Is Declared As Private, Where May The Variable Be Accessed?
What Do You Understand By Private, Protected And Public?
What Is Downcasting ?

What Modifiers May Be Used With An Inner Class That Is A Member Of An Outer Class?
How Many Bits Are Used To Represent Unicode, Ascii, Utf-16, And Utf-8 Characters?
What Restrictions Are Placed On The Location Of A Package Statement Within A Source Code File?
What Is Assembly Condition Codes?
What Is Data Movement?
What Are Kinds Of Processors?
What Are Assembly Attributes?
What Are The Types Of Assemblies?
Explain An Intermediate Language?
What Is Assembly Language?

Accenture Real-Time Interview Questions

What Are The Advantages Of Assembly Language?
What Are The Basic Features Of Pc Hardware?
What Is Binary Number System?
What Is Hexadecimal Number System?
What Is Local Environment Setup?
How To Installing Nasm?
What Are The Assembly Program Sections?
What Is The Data Section?
What Is The Bss Section?
What Is The Text Section?

What Are The Assembly Language Statements?
What Is The Syntax Of Assembly Language Statements?
What Are Memory Segments?
What Are The Processor Registers?
What Linux System Calls?
What Are The Basic Modes Of Addressing ?
What Is The Equ Directive?

Which Location Do You Want To Work In And Why?

RELATED INTERVIEW QUESTIONS

  1. Advanced Java Interview Questions
  2. Core Java Interview Questions
  3. .NET Interview Questions
  4. Ansible Interview Questions
  5. ServiceNow Interview Questions
  6. RPA Interview Questions
  7. Blue Prism Interview Questions
  8. SSIS Interview Questions And Answers
  9. Oracle Performance Tuning Interview Questions
  10. SCCM Interview Questions
  11. ServiceNow Interview Questions
  12. SQL Interview Questions
  13. Docker Interview Questions