You are on page 1of 16

1.

2.
3.
4.
5.
6.

What is the difference between an Inner Class and a Sub-Class?


What are the various access specifiers for Java classes?
Whats the purpose of Static methods and static variables?
What is data encapsulation and whats its significance?
What is a singleton class? Give a practical example of its usage.
What are Loops in Java? What are three types of loops?

7. What is an infinite Loop? How infinite loop is declared?


8. What is the difference between continue and break statement?
9. What is the difference between double and float variables in Java?
10. What is Final Keyword in Java? Give an example.
11. What is ternary operator? Give an example.
12: What are 6 different types of operators in Java?
13. What is default switch case? Give example.
14. Whats the base class in Java from which all classes are derived?
15. Can main() method in Java can return any data?
16. What are Java Packages? Whats the significance of packages?
17. Can we declare a class as Abstract without having any abstract method?
18. Whats the difference between an Abstract Class and Interface in Java?
19. What are the performance implications of Interfaces over abstract classes?
20. Does Importing a package imports its sub-packages as well in Java?
21. Can we declare the main method of our class as private?
22. How can we pass argument to a function by reference instead of pass by
value?
23. How an object is serialized in java?
24. When we should use serialization?
25. Is it compulsory for a Try Block to be followed by a Catch Block in Java for
Exception handling?

26. Is there any way to skip Finally block of exception even if some exception
occurs in the exception block?
27. When the constructor of a class is invoked?
28. Can a class have multiple constructors?
29. Can we override static methods of a class?
31. Is String a data type in java?
33. Why Strings in Java are called as Immutable?
34. Whats the difference between an array and Vector?
35. What is multi-threading?
36. Why Runnable Interface is used in Java?
37. What are the two ways of implementing multi-threading in Java?
38. When a lot of changes are required in data, which one should be a preference to
be used? String or StringBuffer?
39. Whats the purpose of using Break in each case of Switch
Statement?
40. How garbage collection is done in Java?
41. How we can execute any code even before main method?
42. Can a class be a super class and a sub-class at the same time? Give example.
43. How objects of a class are created if no constructor is defined in the class?
44. In multi-threading how can we ensure that a resource isnt used by multiple
threads simultaneously?
45. Can we call the constructor of a class more than once for an object?

46. There are two classes named classA and classB. Both classes are in the same
package. Can a private member of classA can be accessed by an object of classB?
47. Can we have two methods in a class with the same name?
48. How can we make copy of a java object?
49. Whats the benefit of using inheritance?
50. Whats the default access specifier for variables and methods of a class?
51. Give an example of use of Pointers in Java class.
52. How can we restrict inheritance for a class so that no class can be inherited from
it?
53. Whats the access scope of Protected Access specifier?
54. Whats difference between Stack and Queue?
55. In java, how we can disallow serialization of variables?
56. How can we use primitive data types as objects?
57. Which types of exceptions are caught at compile time?
58. Describe different states of a thread.
59. Can we use a default constructor of a class even if an explicit constructor is
defined?
60. Can we override a method by using same method name and arguments but
different return types?
61. A person says that he compiled a java class successfully without even having a
main method in it? Is it possible?
62. Can we call a non-static method from inside a static method?

63. What are the two environment variables that must be set in order to run any Java
programs?
64. Can variables be used in Java without initialization?
65. Can a class in Java be inherited from more than one class?
66. Can a constructor have different name than a Class name in Java?
67. What will be the output of Round(3.7) and Ceil(3.7)?
68: Can we use goto in Java to go to a particular line?
69. Can a dead thread be started again?
71. Is JDK required on each machine to run a Java program?
72. Whats the difference between comparison done by equals method and ==
operator?
73. Is it possible to define a method in Java class but provide its implementation in
the code of another language like C?
74. How destructors are defined in Java?
75. Can a variable be local and static at the same time?
76. Can we have static methods in an Interface?
77. In a class implementing an interface, can we change the value of any variable
defined in the interface?
78. Is it correct to say that due to garbage collection feature in Java, a
java program never goes out of memory?
79. Can we have any other return type than void for main method?

80. I want to re-reach and use an object once it has been garbage collected. How its
possible?
81. In Java thread programming, which method is a must
implementation for all threads?
82. I want to control database connections in my program and want that only one
thread should be able to make database connection at a time. How can I implement
this logic?
83. How can an exception be thrown manually by a programmer?
84. I want my class to be developed in such a way that no other class (even derived
class) can create its objects. How can I do so?
85. How objects are stored in Java?
86. How can we find the actual size of an object on the heap?
87. Which of the following classes will have more memory allocated?
Class A: Three methods, four variables, no object
Class B: Five methods, three variables, no object

88. What happens if an exception is not handled in a program?


89. I have multiple constructors defined in a class. Is it possible to call a constructor
from another constructors body?
90. Whats meant by anonymous class?
91. Is there a way to increase the size of an array after its declaration?
92. If an application has multiple classes in it, is it okay to have a main
method in more than one class?

93. I want to persist data of objects for later use. Whats the best
approach to do so?
94. What is a Local class in Java?
95. String and StringBuffer both represent String objects. Can we compare String and
StringBuffer in Java?
96. Which API is provided by Java for operations on set of objects?
97. Can we cast any other type to Boolean Type with type casting?
98. Can we use different return types for methods when overridden?
99. Whats the base class of all exception classes?
100. Whats the order of call of constructors in inheritiance?

1)What is Java
2)Where it is used?
3)Types of Java Applications
4) What is the difference between JRE and JVM ?
5) What is the purpose of JIT compiler ?
6) Can we save the java source file without any name ?

7) Why java uses the concept of unicode system ?


8) History of Java
9) Features of Java
10)Hello Java Program
11)Program Internal
12)How to set path?
13)Difference between JDK,JRE and JVM
14)Internal Details of JVM
15)Variable and Data Type
16)Unicode System
17)Operators

18)

History of Java

19)

Why Oak name for java language?

20)

Why Java name for java language?

21)

Java Version History

22)

Features of Java

Hadoop Core Java Interview Questions


1. What is the most important feature of Java?
2. what do you mean by platform independence?
3. What is a JVM?
4. Are JVM's platform independent?

5. What is the difference between a JDK and a JVM?


6. What is a pointer and does Java support pointers?
7. What is the base class of all classes?
8. Does Java support multiple inheritance?
9. Is Java a pure object oriented language?
10.

Are arrays primitive data types?

11.

What is difference between Path and Classpath?

12.

What are local variables?

13.

What are instance variables?

14.

How to define a constant variable in Java?

15.

Should a main() method be compulsorily declared in all java classes?

16.

What is the return type of the main() method?

17.

Why is the main() method declared static?

18.

What is the arguement of main() method?

19.

Can a main() method be overloaded?

20.

Can a main() method be declared final?

21.

Does the order of public and static declaration matter in main()

method?

22.

Can a source file contain more than one class declaration?

23.

What is a package?

24.

Which package is imported by default?

25.

Can a class declared as private be accessed outside it's package?

26.

Can a class be declared as protected?

27.

What is the access scope of a protected method?

28.

What is the purpose of declaring a variable as final?

29.

What is the impact of declaring a method as final?

30.

I don't want my class to be inherited by any other class. What should i

do?

31.
32.

Can you give few examples of final classes defined in Java API?
How is final different from finally and finalize()?

33.

Can a class be declared as static?

34.

When will you define a method as static?

35.

What are the restriction imposed on a static method or a static block

of code?

36.

I want to print "Hello" even before main() is executed. How will you

acheive that?

37.

What is the importance of static variable?

38.

Can we declare a static variable inside a method?

39.

What is an Abstract Class and what is it's purpose?

40.
41.

Can a abstract class be declared final?


What is use of a abstract variable?

42.

Can you create an object of an abstract class?

43.

Can a abstract class be defined without any abstract methods?

44.

Class C implements Interface I containing method m1 and m2

declarations. Class C has


provided implementation for method m2. Can i create an object of Class C?

45.
46.

Can a method inside a Interface be declared as final?


Can an Interface implement another Interface?

47.

Can an Interface extend another Interface?

48.

Can a Class extend more than one Class?

49.

Why is an Interface be able to extend more than one Interface but a

Class can't extend


more than one Class?

50.

Can an Interface be final?

51.

Can a class be defined inside an Interface?

52.

Can an Interface be defined inside a class?

53.

What is a Marker Interface?

54.

Which object oriented Concept is achieved by using overloading and

overriding?

55.

Why does Java not support operator overloading?

56.

Can we define private and protected modifiers for variables in

interfaces?

57.

What is Externalizable?

58.

What modifiers are allowed for methods in an Interface?

59.

What is a local, member and a class variable?

60.

What is an abstract method?

61.

What value does read() return when it has reached the end of a file?

62.

Can a Byte object be cast to a double value?

63.

What is the difference between a static and a non-static inner class?

64.

What is an object's lock and which object's have locks?

65.

What is the % operator?

66.

When can an object reference be cast to an interface reference?

67.

Which class is extended by all other classes?

68.

Which non-Unicode letter characters may be used as the first character

of an identifier?

69.

What restrictions are placed on method overloading?

70.

What is casting?

71.

What is the return type of a program's main() method?

72.

If a variable is declared as private, where may the variable be

accessed?

73.

What do you understand by private, protected and public?

74.

What is Downcasting ?

75.

What modifiers may be used with an inner class that is a member of

an outer class?

76.

How many bits are used to represent Unicode, ASCII, UTF-16, and

UTF-8 characters?

77.

What restrictions are placed on the location of a package statement

within a source
code file?

78.

What is a native method?

79.

What are order of precedence and associativity, and how are they

used?

80.

Can an anonymous class be declared as implementing an interface

and extending a
class?

81.

What is the range of the char type?

82.

What is the range of the short type?

83.

Why isn't there operator overloading?

84.

What does it mean that a method or field is "static"?

85.

Is null a keyword?

86.

Which characters may be used as the second character of an identifier,

but not as the


first character of an identifier?

87.

Is the ternary operator written x : y ? z or x ? y : z ?

88.

How is rounding performed under integer division?

89.

If a class is declared without any access modifiers, where may the

class be accessed?

90.

Does a class inherit the constructors of its superclass?

91.

Name the eight primitive Java types

92.

What restrictions are placed on the values of each case of a switch

statement?

93.

What is the difference between a while statement and a do while

statement?

94.

What modifiers can be used with a local inner class?

95.

When does the compiler supply a default constructor for a class?

96.

If a method is declared as protected, where may the method be

accessed?

97.

What are the legal operands of the instanceof operator?

98.

Are true and false keywords?

99.

What happens when you add a double value to a String?

100.

What is the diffrence between inner class and nested class?

101.

Can an abstract class be final?

102.

What is numeric promotion?

103.

What is the difference between a public and a non-public class?

104.

To what value is a variable of the boolean type automatically

initialized?

105.

What is the difference between the prefix and postfix forms of the ++

operator?

106.

What restrictions are placed on method overriding?

107.

What is a Java package and how is it used?

108.

What modifiers may be used with a top-level class?

109.

What is the difference between an if statement and a switch

statement?

110.

What are the practical benefits, if any, of importing a specific class

rather than an
entire package (e.g. import java.net.* versus import java.net.Socket)?

111.

Can a method be overloaded based on different return type but same

argument type ?

112.

What happens to a static variable that is defined within a method of a

class ?

113.

How many static initializers can you have ?

114.

What is the difference between method overriding and overloading?

115.

What is constructor chaining and how is it achieved in Java ?

116.

What is the difference between the Boolean & operator and the &&

operator?

117.

Which Java operator is right associative?

118.

Can a double value be cast to a byte?

119.

What is the difference between a break statement and a continue

statement?

120.

Can 123. How are this() and super() used with constructors?

a for statement loop indefinitely?

121.

To what value is a variable of the String type automatically initialized?

122.

What is the difference between a field variable and a local variable?

123.

What does it mean that a class or member is final?

124.

What does it mean that a method or class is abstract?

125.

What is a transient variable?

126.

How does Java handle integer overflows and underflows?

127.
128.

What is the difference between the >> and >>> operators?


Is sizeof a keyword?

You might also like