Highbridge Capital Interview Question
Java DevelopersTeam: Risk Metrics
Country: United States
Interview Type: Phone Interview
"Class:If want to inherit the class dnt use FINAL"
What if you were inheriting a class that had a variable that wouldn't change for all child classes?
Example: Course Class.
There can be many different courses, but each course MUST have an enrollment maximum of 20. This could be a static final variable, right?
#include<stdio.h>
void main()
{
int a=10,b=2;
b=a+(++a);
printf("%d",b);
}
wht wll be the output this ques??
why we should not use final keyword....??
General:when we dont want to override the class member
for class:when we dont want to create a sub class for a class or to inherit
for method:when we dont want to define the method in the sub class
for field:when we dont want the field to be define the field in the sub class
When u should n't use FINAL
- sarthakiter July 26, 2012Variable:When you know u r gonna change the value of the variable.
Method:If you wanna override the method in child class dnt use FINAL.
Class:If want to inherit the class dnt use FINAL