Core%20java - Interview Questions and Answers for 'At' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


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

   



Core%20java - Interview Questions and Answers for 'At' - 0 question(s) found - Order By Newest

 Q1. How can we create objects if we make the constructor private ?Core Java
a. We can't create objects if constructor is private
b. We can only create objects if we follow singleton pattern
c. We can only create one object
d. We can create new object through static method or static block

Ans.d. We can create new object through static method or static block

 Q2. What will be the output of executing following class ?

public class BuggyBread {

static {
System.out.println("Static Block");
}

{
System.out.println("Initialization Block");
}

BuggyBread(){
System.out.println("Constructor");
}

public static void main(String[] args){
System.out.println("Main Method");
}
}
Core Java
a. Static Block
Main Method
b. Static Block
Instance Initialization Block
Main Method
c. Static Block
Constructor
Main Method
d. Static Block
Instance Initialization Block
Constructor
Main Method

Ans.a. Static Block
Main Method

 Q3. What will be the output upon executing following class ?

public class BuggyBread {

static {
System.out.println("Static Block");
}

{
System.out.println("Instance Initialization Block");
}

BuggyBread(){
System.out.println("Constructor");
}

public static void main(String[] args){
System.out.println("Main Method");
new BuggyBread();
}
}
Core Java
a. Instance Initialization Block
Constructor
Static Block
Main Method
b. Static Block
Instance Initialization Block
Constructor
Main Method
c. Main Method
Static Block
Instance Initialization Block
Constructor
d. Static Block
Main Method
Instance Initialization Block
Constructor

Ans.d. Static Block
Main Method
Instance Initialization Block
Constructor

 Q4. With the following code, Which is a valid way to initialize ?
public class BuggyBread {

   private String element1;

   private String element2;

   private BuggyBread(String element1, String element2){
      this.element1 = element1;
      this.element2 = element2;
   }

   public static class Builder {
   
      private String element1;

      private String element2;

      Builder(BuggyBread buggybread){
         element1 = buggybread.element1;
         element2 = buggybread.element2;
      }

      Builder withElement1(String element1){
         this.element1 = element1;
         return this;
      }

      Builder withElement2(String element2){
         this.element2 = element2;
         return this;
      }

      BuggyBread build(){
         BuggyBread buggybread = new BuggyBread(element1,element2);
         return buggybread;
      }
   }
}
Core Java
a. BuggyBread buggybread = new BuggyBread();
b. BuggyBread buggybread = new BuggyBread("element1","element2");
c. BuggyBread.Builder builder = new BuggyBread.Builder();
d. BuggyBread.Builder builder = new BuggyBread.Builder("element1","element2");

Ans.d. BuggyBread.Builder builder = new BuggyBread.Builder("element1","element2");

 Q5. What will be the output of following ?

public class BuggyBread {

   private int x;
   private Integer y;

   BuggyBread(int x,int y){};

   public static void main(String[] args){
      BuggyBread buggybread = new BuggyBread(1,2);
      System.out.println(buggybread.x);
      System.out.println(buggybread.y);
   }
}
Core Java
a. 0 0
b. 0 null
c. null 0
d. null null

Ans.b. 0 null

 Q6. Which of the following is true for == operator ?Core Java
a. For primitives, == checks if the variables on left and right have same data type
b. For primitives, == checks if the variables on left and right have same value
c. For Objects, == checks if the references on left and right have same data type
d. For Objects, == checks if the references on left and right have same value

Ans.b. For primitives, == checks if the variables on left and right have same value

 Q7. Which of the following is equivalent to following logic ?

Not X && Not Y
Core Java
a. x || Y
b. Not(X || Y)
c. Not(X && Y)
d. Not X && Y

Ans.b. Not(X || Y)

 Q8. Which of the following http response means the resource is not found ?Java EE
a. 500
b. 200
c. 404
d. 400

Ans.c. 404

 Q9. What is Dirty Read in Database Transactions ?Database
a. Data Read by Transaction 2 which hasn't yet updated by Transaction 1
b. Data Read by Transaction 2 which has been updated and commited by Transaction 1
c. Data Read by Transaction 2 which has been updated but not commited by Transaction 1
d. Inability of Transaction 2 to read Data when Transaction 1 is updating.

Ans.c. Data Read by Transaction 2 which has been updated but not commited by Transaction 1

 Q10. Which of following annotation is used to initialize objects before executing set of tests ?Junit
a. @Test
b. @Ignore
c. @After
d. @Before

Ans.d. @Before

 Q11. Which of the following is not true for static keyword ?Core Java
a. Static members are shared by all objects of the class.
b. We can override static methods.
c. Static methods operate on static variables only.
d. Static Elements are accessed using class name.

Ans.b. We can override static methods.

 Q12. What is Lazy Initialization in Hibernate ?Hibernate
a. Feature to load the dependencies from Cache
b. Feature to load all objects and relationships in advance before they can be used
c. Feature to not load dependencies and relationship in advance and load when required
d. Feature to not load the dependencies and relationships at all

Ans.c. Feature to not load dependencies and relationship in advance and load when required

 Q13. Which of the following is not the benefit of Lazy Initialization in Hibernate ?Hibernate
a. Laod When required provides better performance
b. Object stays lighter
c. Less number of Database calls
d. Less load on Database

Ans.c. Less number of Database calls

 Q14. The use of volatile keyword facilitates ..Core Java
a. Making Use of Cache for better Performance
b. Avoiding use of Cache
c. Making use of Backward as well as Forward Cache
d. Keeping only one copy of variable in Cache

Ans.b. Avoiding use of Cache

 Q15. Static Polymorphic in Java is achieved through .. Core Java
a. Method Overloading
b. Method Overriding
c. Variable Overloading
d. Variable Overriding

Ans.a. Method Overloading

 Q16. Which of following are serialized ?Core Java
a. static variables
b. transient variables
c. instance variables
d. method local variables

Ans.c. instance variables

 Q17. Which of the following is not true for Hibernate Cache ?Hibernate
a. First level cache is enabled by default
b. First level Cache is Session specific
c. First level cache is considered global
d. First level Cache came with Hibernate 1.0

Ans.c. First level cache is considered global

 Q18. Which of the following is not an Hibernate AnnotationHibernate
a. @Id
b. @JoinTable
c. @ManyToMany
d. @Autowired

Ans.d. @Autowired

 Q19. Which of following is not Spring MVC annotation ?Spring
a. @Autowired
b. @Controller
c. @JoinColumn
d. @Transactional

Ans.c. @JoinColumn

 Q20. In majority of the cases, the following join will give maximum number of results ?Database
a. Inner Join
b. Outer Join
c. Left Join
d. Right Join

Ans.b. Outer Join

 Q21. Which if the following is true for SQL Joins ?Database
a. Left Join and Right Join gives equal number of Results
b. Outer Join and Inner Join gives equal number of Results
c. Inner Join gives maximum number of results records
d. Inner Join gives minimum number of result records

Ans.d. Inner Join gives minimum number of result records

 Q22. Listeners are example of ..Design
a. Factory design Pattern
b. Abstract Factory Design Pattern
c. Singleton Design Pattern
d. Observer Design Pattern

Ans.d. Observer Design Pattern

 Q23. Which of the following is a configuration management tool ?Tool
a. Github
b. Jira
c. Tomcat
d. Eclipse

Ans.a. Github

 Q24. Which of following is not a configuration management tool ?Tool
a. SVN
b. Jira
c. GitHub
d. Clearcase

Ans.b. Jira

 Q25. Which of the following Design pattern has been used with Hibernate Criteria ?Hibernate
a. Filter
b. Prototype
c. Builder
d. Observer

Ans.a. Filter

 Q26. Which of following is not core interface of Hibernate ?Hibernate
a. Session
b. Transaction
c. SessionFactory
d. TransactionFactory

Ans.d. TransactionFactory

 Q27. Which of the following is not true for Prepared Statements ?Database
a. Prepared Statements provides better performance
b. Prepared Statements prevent SQL Injection attacks
c. Prepared Statements provide ORM capabilities
d. Prepared Statement provides DB side caching

Ans.c. Prepared Statements provide ORM capabilities

 Q28. Which of the following session method is used to disassociate / disconnect all objects from the sessionHibernate
a. Clear
b. Evict
c. Close
d. Merge

Ans.a. Clear

 Q29. Which of the following session method is used to disassociate / disconnect a particular object / entity from the sessionHibernate
a. Clear
b. Evict
c. Close
d. Merge

Ans.b. Evict

 Q30. Which of following is not the resolution for preventing LazyInitializationException?Hibernate
a. Set fetch=FetchType.EAGER for Dependent entity mapping
b. Make sure that we are accessing the dependent objects before closing the session
c. Make sure that we are accessing the dependent objects after closing the session
d. Wrap the complete access within Transaction

Ans.c. Make sure that we are accessing the dependent objects after closing the session


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

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

Company Name:
Questions Asked: