Technical Interview: Computer Science and Engineering: OOPS

Doorsteptutor material for competitive exams is prepared by world's top subject experts: get questions, notes, tests, video lectures and more- for all subjects of your exam.

Computer Science and Engineering


90) Define four main concepts of OOPs: Inheritance Polymorphism, Encapsulation, Data Abstraction?

91) What is difference between static polymorphism and dynamic polymorphism?

92) Explain relationship between class and object?

93) Using which access modifier does one can achieve data abstraction?

94) List some of the primitive data types with their sizes in java?

95) What are the different scopes for Java variables?

96) What elements does array ‘r’ contains in the below program?

public static void main () {

int [] p = {1,2, 3} ,

int [] q = {4,5, 6} ,

int [] r = new int [p. length + q. length] ,

int I,

for (i = 0; i < p. length; j ++)

r [i ++] = q [j] ,

return r,


97) public static void main (String args [] )


boolean X = true,

int y = (int) X,


Does above program executes without error?

98) write a class which resembles following scenario?

A mobile phone object, which has the plane number and have two functions “call” and “sms.” ‘call’ method takes the phone number and ‘sms’ method takes the phone number as well the text. No need to implement the ‘call’ and ‘sms’ methods just give signature of methods and the class structure?

99) How many arguments does default constructor contains?

100) List all the access specifiers in the java?

101) How many ways we can write “for loops” in java?

102) If we don՚t provide the access specifier, which access specifier does compiler takes?

103) How ‘protected’ access modifier works? If any class member is defined as ‘protected,’ where can it be used?

104) What is difference between “this” and “super” objects?

105) What is the purpose of garbage collector?

106) Does method overloading can have different return types?

107) What does constructor overloading mean?

108) If we pass an object to the method, can we say it ‘pass by value’ ?

109) Is a string mutable or immutable? And why?

110) String s = “India,”

String k = “India,”

String p = new String ( “India” ) ,

How many String objects does JVM creates?

111) What is difference between class variable and instance variable? And using what keyword can we create class variables?

112) How to concatenate two string variables in java?

113) Write a program to print the letters from 10th to 22nd in the following sentence “India is great country with ancient cultures” ?

114) What is meant by string tokens? Write a program to separate following string to tokens:

115) Give the syntax of creating inheritance between two classes?

116) What is the output of below program?

Public class recurrence {

Public static void main (String [] args) {

Xmethod (5) ,


public static void xmethod (int n) {

if (n > 0) {

xMethod (n-1) ,

System. out. print (n + “” ) ,




117) Class A


public void print ()


System. out. printIn ( “I am in A” ) ,




Class B extends Class A


Public void print () {

System. outprintIn ( “I am in B” ) }


public static void main ()

{An obj = new B () ,

Obj. print () ,


What is the output of above program?

118) How many classes can inherit in java?

119) How do I call the super class constructer from child class constructor?

120) final class A


// …


Class B extends A


// …


Point the mistakes in the above code?

121) What is method overriding? How it is different with method overloading?

122) What are the points need to be taken care in method overriding?

123) Can we override the final methods of super class?

124) What is purpose of having abstract class in java? When a class can be called abstract class?

125) Is it compulsory to child class to implement all the abstract methods of abstract class? If not, what happens?

126) What is interface? How it is different from abstract class?

127) What keyword do we use to create child class of interface?

128) What happens if we don՚t implement the methods of interface?

129) How many interfaces can inherit in java?

130) What is marker interface?

131) How can we inherit interface with another interface?

132) public interface Marker {


Is above a valid interface?

133) What is enum? Define enum of calendar months?

134) What is name of methodology which converts primitive type to Object

e. g. : int to Integer, float to Float?

135) Arraylist < String > a = new ArrayList < String > () ; In the above statement what kind of object we can store in the ArrayList a?

136) How many types of inner class are there in java?

137) class Outer Class


private int privInt = 10,

class InnerClass


public void accessOuter ()


System. out. printIn ( “The outer class՚s privInt is” + PrivInt) ,




Write a statement to create an object of the InnerClass.

138) What type of collection preserves insertion order? Name some of the classes of it?

139) What type of collection support key value pair? Name some of the classes of it?

140) What type of collection avoids duplication of elements? Name some of the classes of it?

141) If I want to have non duplicate elements with insertion order, then what type of collection object, I must choose?

142) What type of collections are best suitable for sorting?

143) What is the difference between Vector and ArrayList?

144) Write a problem to iterate the Arralist and print every element in the list?

145) Write a program to iterate the HashMap and print every value in it?

146) What is difference between comparable and comparator? And why they are used?

147) Public static void main (String args [] )


HashMap < String, String > map = new

HashMap < String, String > () ,

map. put ( “A,” “Alpha” ) ,

map. put ( “B,” “Beta” ) ,

map. put ( “A,” “Apple” ) ,

system. out. printIn (map. get ( “A” ) ) ,


What value does ‘A’ print?

148) What is difference between exception and error?

149) Give the syntax of handling exception in the java?

150) Can we have multiple catch block for a single try?

If yes, what is the precaution we need to take?

151) When does the final block executes?

152) public static void main (String args [] )




// code which raises exception


Catch (Exception e)


System. out. printIn ( “In catch” ) ,

return 0,




System. out. printIn ( “In Final” ) ,



What is the output of the program in case of exception?

153) When “throw” and “throws” are used respectively?

154) Which class you must inherit to create a user defined “Exception” ?

155) Among the checked and unchecked exception, which one must need to handle?

156) How many ways can we create threads in java?

157) What are the difference states of threads in java?

158) Which method wakes up sleeping thread?

159) What is difference between notify () & notify All () ?

160) What happens if a start method is not invoked and the run method is directly called?

161) How can we achieve synchronization in java?

162) What is CLASSPATH?

163) Give the command to compile the java file and give the command to run the same program?

164) What is JVM?

165) Define package? And how to add certain package to class path?

Developed by: