Interview Questions - Technical Round
Date : 11 Feb, 2018
1.if i have a object then how to get Class type of that object?
2.if i have an object how to check whether the object is belongs to which class?
3.what are OOPs principles? explain them? where you found them in jdk provided classes?
Set<Test> set=new HashSet<>();
Test t=new Test();
how many objects will be added to Hashset and what is the size of the Hashset? explain
5. what are the differences b/n set and list
6.if i add 2 different objects to set by using same referance variable, how many objects will be added to set?
Test t=new Test();
HashSet<Test> tests=new HashSet<>();
7.i have list of employees i want to remove a employee whos id is 1 write the logic?
wrote for each loop and removed one object..
is there any problem with in this code? do we get any exception?
List<Test> tests=new ArrayList<>();
8.int add() and long add() are in same class are they overloaded or duplicate methods? if i have long add() in super class int add() in sub class is it valid overriding?
9.In a class i have void add(Employee) void add(Student) and i called add(null) in main method which method will be called?
10.parent method is throwing checked-exception is it mandatory that child class method should also throw?
11.what are checked and unchecked exceptions?
12.how to create checked and how to create un-checked exception?
13.parent method is throwing both Checked and unchecked exceptions then what child should be throwing?
14.what is cascade in hibernate?
15.what is many-many relationship, how many tables we need to have in many-many relationship?
16.what are default methods in interfaces? what is the purpose of them?
17.If i have 100 methods in an Interface if i want to provide implementaion is it mandatory that i need to override 100 methods?
Coding Round Question
1.if i have an int which has some values, i have an index place called (Breaking point) which fulfills below features
Sum of all the elements less than breaking point sum is
exactly equals to the
product of all the elements grater than breaking point to end of that array
Sum is ZERO
find all such breaking points and put them in a Set and write test cases
case-1:- if given array is empty or null then throw IllegalArgumentException
case 2: [1,2,1] has break point at index 1
case 3:[5,0,-5,-4] has 0,3 as breaking points
Write JUnit test cases for all possibilities including exception paths?