You are on page 1of 3

Answer the following questions with Yes/No and then give reason/concept?

1. A class implementing an interface must redefines all methods and constants of an interface.
2. A static inner class would have a direct access to all the variables and methods of an outer class?
3. A static method is shared among all the objects of a class in which it is declared?
4. A static method of a class can be called by an object of that class?
5. If a class has only a parameterized constructor, then creating an object of that class using a default constructor is allowed?
6. Can we instantiate an abstract class?
7. Can we instantiate an interface?
8. Abstract methods of a class are its child class responsibility.
9. A method declared as final can be override.
10. Can we define a method in an interface?
11. Can we create a reference variable of an interface?
12. A child class reference variable can refere to an object of its parent’s sibling.
13. Why we cannot create a reference variable of an abstract class?
14. An abstract class can be declared as final?
15. The value of a variable declared and initialized in an interface can be changed in the class which implements that interface.
16. If a local variable of a method has the same name as an instance variable/data member of a class,
then when executing the method instance variable’s value will be used.
17. If a class has abstract methods, then it can be instantiated.
18. Can we have a concrete method in an interface?
19. Why we do not have an abstract method in an interface?
20. Objects communication is realized/performed by calling their corresponding methods.
21. Multiple inheritance is supported in java through method overriding?
22. Why is the variables in an interface are not final?
23. Access to object’s data members through its member functions is information hiding.
24. Can we assign an interface a private access modifier?
25. In interface variables are implicity constants?
26. A class declared as final can be inherited.
27. Does a static variable share value with all objects of a class in which it is declared?
28. Can we inherit an interface from another interface?
29. If a class has an abstract method. Will that class be declared as an abstract class?
30. Can we declare abstract methods as private?
31. If a class implements an interface and does not provide the implementations of all the methods declared in an interface.
Will that class be declared as an abstract class?
32. Can a child class be extended from two parent classes?
33. How java implements multiple inheritance?
34. Can a child class object is assigned to the object of its sibling?
35. Can a method has a same name as a class?
36. A class that is an inner class and is declared without a name and typically appears inside
a method declaration is reffered as anonymous class.
37. Call to an overridden methods are resolved at compile time?
38. A static method of a class can access instance variables of that class?
39. A static method of a class can access another method of that class?
40. Manipulating the values of private variables through Mutator functions decreases the control over the private data memebers?
41. When a class implements an interface it must redefine all the methods in the interface?
42. Can a member function of a class be declared as private? For what use?
43. If a class has two static blocks, then they execute in order of they appeared in the code.
44. Method overriding allows the creation of several methods with the same name and differ from each
other in terms of the number and type of the parameters.
45. An anonymous class implements an interface and provides a default implementation (with an empty method body)
of each method in the interface
46. A class can implement two interfaces each of which has the same constant variable?
47. The instanceof operator is used to test whether the object is an instance of the specified type (class or subclass or interface)?
48. When an executing program does not properly release the resourece is reffered as resource leak?
49. A method which depends upon instance variables to read and change they should be declared as static?
50. The code that performs a task in response to an event is called an event handler?
51. If a method works only on argument variables and local variables, it can be declared as non static?
52. An interface can extend any number of interfaces using the implements keyword.
53. Garbage collection is a mechanism used to allocate space for objects?
54. Method signature includes its name, number and type of its parameters and its return type.
55. Method overloading allows a subclass to implement a method with the same mehod signature as in its parent class.
56. Notifying a class (that implements respective event listener) an event has occurred is called registering the event?
57. Static methods can refer to/use ‘this’ keyword?
58. Static methods cannot refer to/use ‘super’ keyword?
59. A class that is declared without a name and typically appears inside a method declaration is anonymous class.

SOLUTION

Answer the following questions with Yes/No and then give reason/concept?
1. Can a method has a same name as a class?
YES
2. Does finally block always executes even if the exception occurs or not?
YES

Page 1 of 3
3. If a class has only a parameterized constructor, then creating an object of that class using a default
constructor is allowed or not?
Not Allowed
4. Can we instantiate an abstract class?
NO, can only create a reference variable.
5. Can we instantiate an interface?
NO, can only create a reference variable.
6. Can we define a method in an interface?
NO
7. Can we create a reference variable of an interface?
YES
8. Why we cannot create a reference variable of an abstract class?
We can create a reference variable of an abstract class.
9. Can we use a catch{} block without a try{} block?
NO
10. Can we use multiple catch{} blocks with a single try{}?
YES
11. Can we have a concrete method in an interface?
NO
12. Why we do not have an abstract method in an interface?
All methods are by default abstract.
13. Why is the variables in an interface are not final?
By default final
14. Does a static variable share value with all objects of a class in which it is declared?
YES
15. Can we inherit an interface from another interface?
YES
16. If a class has an abstract method. Will that class be declared as an abstract class?
YES
17. If a class implements an interface and does not provide the implementations of all the methods
declared in an interface. Will that class be declared as an abstract class?
YES
18. A static method of a class can access instance variables of that class?
YES if the instance variable is static otherwise not allowed.
19. A static method of a class can access another method of that class?
Yes if it is static too.
20. A static inner class would have a direct access to all the variables and methods of an outer class?
NO
21. A static variable is shared among all the objects of a class in which it is declared?
YES
22. A static method of a class can be called by an object of that class?
Yes but bad coding

23. Manipulating the values of private variables through Mutator functions decreases the control over
the private data memebers?
NO, it increases the control compared to if we manipulate the varibales by giving the direct
access.
24. Can a member function of a class be declared as private? For what use?
YES, for use within the class. Can not be called outside.
25. A method which depends upon instance variables to read and change they should be declared as
static?
NO
26. If a method works only on argument variables and local variables, it can be declared as non static?
Page 2 of 3
YES, but can also be declared as static.
27. Garbage collection is a mechanism used to allocate space for objects?
Garbage collection is a mechanism used to deallocate space of objects when no reference exis to
tht object.
28. ‘this’ in an inner class refers to the object of an outer class?
NO
29. Static methods can refer to/use ‘this’ keyword?
NO.
30. Static methods cannot refer to/use ‘super’ keyword?
NO

Page 3 of 3

You might also like