2
Exercise2 1. How to define a constant variable in Java? 2. Can a source file contain more than one Class declaration? 3. Can a class declared as private be accessed outside it's package? 4. Can a class be declared as protected? 5. What is the impact of declaring a method as final? 6. I don't want my class to be inherited by any other class. What should i do? 7. Can you give few examples of final classes defined in Java API? 8. How is final different from finally and finalize? 9. Can we declare a static variable inside a method? 10. What is an Abstract Class and what is it's purpose? 11. Can a abstract class be declared final? 12. What is use of a abstract variable? 13. Can you create an object of an abstract class? 14. Can a abstract class be defined without any abstract methods? 15. 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? 16. Can a method inside a Interface be declared as final? 17. Can an Interface implement another Interface? 18. Why is an Interface be able to extend more than one Interface but a Class can't extend more than one Class? 19. Can a class be defined inside an Interface? 20. Can an Interface be defined inside a class? 21. What is a Marker Interface? 22. If i only change the return type, does the method become overloaded? 23. Can we define private and protected modifiers for variables in interfaces? 24. What modifiers are allowed for methods in an Interface? 25. What modifiers are allowed for methods in an Interface? 26. Can a Byte object be cast to a double value? 27. When can an object reference be cast to an interface reference? 28. Which non-Unicode letter characters may be used as the first character of an identifier? 29. What restrictions are placed on method overloading? 30. What is casting? 31. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters? 32. If a class is declared without any access modifiers, where may the class be accessed? 33. Does a class inherit the constructors of its superclass? 34. What is the difference between a while statement and a do statement? 35. When does the compiler supply a default constructor for a class? 36. What is numeric promotion? 37. What restrictions are placed on method overriding? 38. What are the practical benefits, if any, of importing a specific class rather than an entire package ? 39. What is the difference between method overriding and overloading? 40. What is constructor chaining and how is it achieved in Java ? 41. What is the difference between the Boolean & operator and the && operator? 42. What is the difference between a break statement and a continue statement? 43. How are this() and super() used with constructors? 44. What does it mean that a method or class is abstract? 45. What is the difference between an Interface and an Abstract class? 46. What are pass by reference and passby value? 47. What is the difference between a constructor and a method? 48. Can an application have multiple classes having main method? 49. Can I import same package/class twice? Will the JVM load the package twice at runtime? 50. What are Checked and UnChecked Exception?

Exercise 2

Embed Size (px)

DESCRIPTION

java excercise 2

Citation preview

Page 1: Exercise 2

Exercise2

1. How to define a constant variable in Java? 2. Can a source file contain more than one Class declaration? 3. Can a class declared as private be accessed outside it's package? 4. Can a class be declared as protected? 5. What is the impact of declaring a method as final? 6. I don't want my class to be inherited by any other class. What should i do? 7. Can you give few examples of final classes defined in Java API? 8. How is final different from finally and finalize? 9. Can we declare a static variable inside a method? 10. What is an Abstract Class and what is it's purpose? 11. Can a abstract class be declared final? 12. What is use of a abstract variable? 13. Can you create an object of an abstract class? 14. Can a abstract class be defined without any abstract methods? 15. 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? 16. Can a method inside a Interface be declared as final? 17. Can an Interface implement another Interface? 18. Why is an Interface be able to extend more than one Interface but a Class can't extend more

than one Class? 19. Can a class be defined inside an Interface? 20. Can an Interface be defined inside a class? 21. What is a Marker Interface? 22. If i only change the return type, does the method become overloaded? 23. Can we define private and protected modifiers for variables in interfaces? 24. What modifiers are allowed for methods in an Interface? 25. What modifiers are allowed for methods in an Interface? 26. Can a Byte object be cast to a double value? 27. When can an object reference be cast to an interface reference? 28. Which non-Unicode letter characters may be used as the first character of an identifier? 29. What restrictions are placed on method overloading? 30. What is casting? 31. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters? 32. If a class is declared without any access modifiers, where may the class be accessed? 33. Does a class inherit the constructors of its superclass? 34. What is the difference between a while statement and a do statement? 35. When does the compiler supply a default constructor for a class? 36. What is numeric promotion? 37. What restrictions are placed on method overriding? 38. What are the practical benefits, if any, of importing a specific class rather than an entire

package ? 39. What is the difference between method overriding and overloading? 40. What is constructor chaining and how is it achieved in Java ? 41. What is the difference between the Boolean & operator and the && operator? 42. What is the difference between a break statement and a continue statement? 43. How are this() and super() used with constructors? 44. What does it mean that a method or class is abstract? 45. What is the difference between an Interface and an Abstract class? 46. What are pass by reference and passby value? 47. What is the difference between a constructor and a method? 48. Can an application have multiple classes having main method? 49. Can I import same package/class twice? Will the JVM load the package twice at runtime? 50. What are Checked and UnChecked Exception?

Page 2: Exercise 2