top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

I don't want my class to be inherited by any other class. What should i do?

+1 vote
483 views
I don't want my class to be inherited by any other class. What should i do?
posted Jan 4, 2017 by Dhaval Vaghela

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+3 votes
 
Best answer

You can use final keyword before the class name. See this example
http://ideone.com/16t4tJ

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
final class A{
}
class B extends A{

}
class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        B b=new B();
    }
}
answer Jan 4, 2017 by Shivam Kumar Pandey
Similar Questions
+2 votes
public class ServletClassName extends HttpServlet {
//declare instance variables for the servlet
int  instanceVar ; // not thread−safe
// overriding the Generic Servlet.init ( )
@Override
public void init ( ) throws ServletException {
// initialize instance variables, etc.
instanceVar = 0 ;
}
. . .
}

Per each page request, in the service() method (which eventually will be either doGet(), doPost(), or whatever),
you can manipulate instance variables.

Write a Servlet that counts the total number of visits (how many times it's being visited from all clients). The Servlet should display the following information

• Total Page Visits:
• Client Remote Address:
• Client Host Address: <client_fully_qualied_url__or__client_IP_address>

The last two can be obtained from the HttpServletRequest, Refer to the Java EE API

then how can re-do these using the Java API for HttpSession.

+1 vote

If an Employee class is present and its objects are added in an arrayList.

0 votes

In an app there is a floating icon of download. I just want, when I open that page icon should come in screen with bouncing effect. App supporting api version > 8.

Please help.

...