You are on page 1of 9

Java Q & A

1. What is IDE?
Integrated Development Environment.

2. What types of IDE are there?


Eclipse, IntelliJ IDEA, Android Studio.

3. What is java?
Java is a popular software programming language.

4. What is Importance of Java?


Java is used to develop Desktop, Web, Mobile and Enterprise Applications.

5. What is JDK, JRE, & JVM?


JDK – Java Development Kit: Contains collection of tools and libraries necessary for
developing java based software applications.
JRE – Java Runtime Environment: It’s the implementation of JVM, where java source
code is compiled and converted to java byte code. It contains JVM, Class Libraries and
java class loader.
JVM – Java Virtual Machine: is an abstract machine that provides runtime
environment where java byte code is executed.

6. What is the difference between JDK and JRE?


JDK is for development purpose, JRE is for running the java programmes.

7. What technologies that depend on core java?


Android, Cloud computing, Selenium testing, Advanced java and many more.

8. How many types is java divided into?


Two types: 1. Core Java
2. Advance Java
9. What are the features of java?
Simple, Object oriented, High performance, Platform independent, secure and many
more.

10. What are the five elements of java?


1. Variables
2. Methods
3. Constructors
4. Instance Blocks
5. Static Blocks

11. What is variables?


Variables are used to store the values into the memory to achieve project
requirements.

12. What is methods?


Methods is a behaviour, where logics are written, data is manipulated and all actions
are executed.

13. What is constructors?


Constructor is a special method that is used to initialize objects.

14. What is instance blocks?


Instance blocks is where logic is written and executed during object creation.

15. What is static blocks?


Static blocks is where logic is written and has Static keyword.

16. What data types are there in java?


Two types of data types: 1. Primitive
2. Non Primitive
In Primitive there are two types: 1. Numeric
2. Non Numeric
In numeric data types are: byte, short, int, long, double and float
In non numeric data types are: character and Boolean

In non primitive data types are: strings, arrays, user defined classes.

17. How many types of variables are there?


Three types of variables: 1. Local variable
2. Instance variable
3. Static variable

18. What’s the difference between instance and static variable?


Static variable only has a single copy, whereas instance variables can have multiple
copies.

19. How do you access instance variable?


Through object creation.

20. How do you access static variables?


Through class name or directly.

21. What is java identifiers?


Any name in java, such as variable name, class name, method name or interface
name.

22. What is modifiers in java?


Modifiers are keywords.

23. How many types of modifiers is there?


Two types: 1. Access Modifiers
2. Non Access Modifiers

24. Why do we need access modifiers?


To set access levels.

25. What are the access modifiers?


Default – visible to package, no modifiers are needed.
Private – visible to class only
Public – visible to the world
Protected – visible to package and all subclasses.

26. Which gives least and most access?


Private – least access
Public - most access

27. What are the non-access modifiers?


Static
Final
Abstract

28. What are java oops concept?


Object oriented Programming Concepts:
Class
Object
Polymorphism
Encapsulation
Inheritance
Abstraction

29. What is class?


Class is a logical entity, which contains the logic of the application.
30. What is object?
object is an instance of the class, it’s a physical entity and represents the memory.

31. What is inheritance?


It’s process of getting properties and behaviour from class to another.

32. How do you achieve inheritance?


By using extends keyword, It makes relationship between two classes.

33. What is a parent (super/base) class?


It’s the class which is providing the properties and behaviour.

34. What is a child (sub/derived) class?


It’s the class which is acquiring the properties and behaviour.

35. Which class is recommended to create object and why?


We should create object at child class, because then it’s possible to access parent
class properties and behaviours.

36. What is the root of every class in java?


Object class. Every class of java is a child of object class directly or indirectly.

37. How many types of inheritance are there?


Five types:
1. Single Inheritance
2. Multiple Inheritance
3. Multilevel Inheritance
4. Hierarchical Inheritance
5. Hybrid Inheritance
38. Which two are not possible in java and why?
Multiple and Hybrid Inheritance is not possible, as it generates ambiguity problem.

39. How do you prevent inheritance?


To declare the class by using Final modifier.

40. How do you represent current class object?


by using this keyword.

41. How do you represent supper class object?


By using super keyword.

42. Is it possible to create object for both parent and child class?
Yes it’s possible.

43. Which is default package in java?


Java.lang package is default package.

44. What is polymorphism?


Something that can be exhibited in more than one form.

45. How many types of polymorphism are there?


Two types: 1. Compile time – Method Overloading
2. Runtime – Method Overriding.

46. What types of overloading is there in java?


1. Method Overloading

2. Constructor Overloading

3. Operator Overloading
47. What is method overloading?
Method overloading is if two methods have the same name but different number of
arguments or same number of arguments with different data types.

48. How can method overloading be achieved?


1. Same method names having different number of arguments.
2. Same method names having same number of arguments with different
data types.
3. Same method names having same number of arguments with different
data type sequence.
49. How many classes are required to achieve overloading?
One.

50. How many methods can be overloaded?


Multiple.

Note: same rule applies to constructor overloading.

51. Is it possible achieve operator overloading?


Java does not support operator overloading with + being the only exception.

52. What is overriding?


If the child class is not satisfied with parent class method implementation, then it is
possible to override that method as per child class requirement.

53. How can overriding be achieved?


To achieve this, we would require inheritance relationship between two classes.

54. In overriding what must be the same?


The child and parent class method signature must be the same.
55. How can you prevent method overriding?
1. Declare parent class method with final non access modifier.

2. Declare method using private access modifier.

3. Keyword static method, as it has a bond with class when loaded.

56. How many pre-defined packages does java contain?


Java contains 14 predefined packages.

57. Explain final modifier in more depth?


 Final modifier can be applied to class, method, or variable.
 if class is declared as final, you cannot extend that class.
 If method is declared as final, you cannot override that method.
 If variable is declared as final, you cannot override that value.

58. What is abstraction?


Abstraction is a process of hiding certain details and showing only essential
information to the user.

59. What is abstract method?


It’s a method which has declaration but no implementation. (no method body, no
curly brackets).

60. Who provides implementation for abstract method?


Child class is responsible.

61. How do you represent abstract class?


By using abstract modifier.

62. Must an abstract class have an abstract method?


No, but if the method is abstract then the class must also be abstract.
63. What is not possible in an abstract class and why?
Creation of an object is not possible, because it contains unimplemented methods.

64. How can you prevent object creation?


By using abstract modifier.

65.

You might also like