This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
long variable has default value of 0L if defined as an instance/static variable.
float variable has default value of 0.0f if defined as an instance/static variable.
double variable has default value of 0.0d if defined as an instance/static variable.
char variable has default value of '\u0000' if defined as an instance/static variable.
String variable has default value of null if defined as an instance/static variable.
Object variable has default value of null if defined as an instance/static variable.
boolean variable has default value of false if defined as an instance/static variable.
Q 8 - Which of the following is true about public access modifier?
Public access modifier is used to make variables, methods and constructors accessible to any class.
Q 9 - Which of the following is true about protected access modifier?
Variables, methods, and constructors which are declared protected can be accessed by any class lying in the same package.
Q 10 - Which of the following is true about private access modifier?
Private access modifier is used to restrict access to variables, methods and constructors to member of same class only.
Q 11 - Which of the following is true about super class?
All of the above are correct.
Q 12 - Which of the following stands true about default modifier of class members?
By default, variables, methods and constructors can be accessed by any class lying in the same package.
Q 13 - Which of the following is false about String?
String is a object.
Q 14 - Which of the following is true about String?
String object is immutable so that once it is created a String object cannot be changed. Since String is immutable it can safely be shared between many threads which are considered very important for multithreaded programming.
Q 15 - What is polymorphism?
Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.
Q 16 - What is inheritance?
It is the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order.
Q 17 - What is Abstraction?
It refers to the ability to make a class abstract in OOP. It helps to reduce the complexity and also improves the maintainability of the system.
Q 18 - What is Encapsulation?
It is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. Therefore encapsulation is also referred to as data hiding.
Q 19 - What is an Interface?
An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface.
Q 20 - What is an immutable object?
An immutable object can't be changed once it is created. String objects are immutable.
Q 21 - What is local variable?
Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and it will be destroyed when the method has completed.
Q 22 - What is instance variable?
Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded.
Q 23 - What is class variable?
Class variables are variables declared with in a class, outside any method, with the static keyword.
It is not mandatory to have a default constructor in a class.
Inheritance represets IS-A relationship providing code reusablity . Consider the following statement: Circle is a Shape. Here Shape is super class and Circle is a child class extends the super class Shape.
|Question Number||Answer Key|