Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

xv. If a valid class implements the Comparable interface but does not override t

ID: 3920110 • Letter: X

Question

xv. If a valid class implements the Comparable interface but does not override the compareTo method, what can be said about the class? xvi. Explain why a class cannot be both abstract and final xvii. Briefly describe the differences between method overloading and method overriding. xvii What is super in is super in Java? xix. Briefly describe the use of super in a constructor xx. In a method body, what is this and what can you do with it? xxi. Java provides eight primitive wrap they are, xxii. Can a Java class have no constructors? (Explain your answer.) xoxd. Java provides eight primitive wapper classes. Explan what they are xxiii. What is QOverride?

Explanation / Answer

xv) If we implements the comparable interface and if we didnt override the compareTo() method then the class must be abstract class.

_________________

xvi) A class cannot be both abstract and final because , if a class is declared as abstract we can extend that class and can provide the method implementations for the abstract methods in the child class.But if we declared that abstract class as final we cant provide the child class .Thats why a class cannot be declared as both abstract and final.

_____________

xvii)

Method over loading: Writing two or more methods with the same name but with different method signatures is call as method overloading.

Ex: add(int a, int b)—this method is having two parameters of type int.

   add(int a,int b,int c)—this method is having 3 parameters of type int.

Method overriding: if the subclass has the same method as declared in the parent class is called as method overriding.

_____________

xviii) super is a keyword : it is used in the sub class method definition to call a method which is defined in the parent class.Only Public and Protected methods can be called by using the super keyword.

It is also used in sub class constructor to call the immediate super class constructor.

_____________

xix) We can use the super key word in the sub class constructor to call the immediate super class constructor.

_____________

xx) this keyword is used to refer the current class instance variables.

_____________

xxi) the 8 Wrapper classes are Boolean,Character,Byte,Short,Integer,Long,Float,Double

_____________

xxii) We can create a java class with out any constructor .If we didn’t provide any constructor inside the class while compiling jvm will check whether our class is having any constructor or not.If not it will provide the zero argumented constructor .

_____________

xxiii) if we want to override the super class method in the sub class we have to provide the @override annotation .

___________Thank You