Bandi Chandrasekhar Reddy

Bandi Chandrasekhar Reddy

class A is there i want restrict this class , without creating an Object how can do?, it should be inheritance possible, & should not be instanciated.?

View Answers

September 6, 2012 at 3:57 PM

You can restrict the class by making the constructor of a class private.Since the private modifier is accessible withing the class, when a class outside this class tries to instantiate this class it gives error as the class cannot be instantiated.

You can also restrict the class by giving abstract key word to the class. Only abstract classes can not be instantiated.









Related Tutorials/Questions & Answers:
Bandi Chandrasekhar Reddy
Bandi Chandrasekhar Reddy   class A is there i want restrict this class , without creating an Object how can do?, it should be inheritance possible, & should not be instanciated.?   You can restrict the class
connection to the printer - Development process
connection to the printer  hi deepak this is sampath reddy, am facing the problem with connecting the peinter through java.How can i connect.../code Regards Sampath Reddy
Advertisements
java - AOP
java  Hi RoseindiaTeam, sub: difference between class loading and execution time in spring? Thank You. Ramesh Reddy T
features - Java Beginners
features  How can i use the dictionary in Java.Is there this feature in C if so inform me.. thank you..... regards.. cheruvu Jaanu Reddy
java code - Development process
java code  hi, this is sampath, how to acchive the batch processing in java or batch process base java thread. can u send the code and brief explanation. thanks and regards sampath reddy
java and xml - XML
java and xml  Hi Deepak, I want learn xml and java(applications). Which editor is best usefull(trial--version) in my applications. (myeclipse--how it is help to me?) Thank You. Ramesh Reddy T. 
provide code in servlets,javascript,jsp - JavaMail
solution to this   Hi chandrasekhar, I am sending you a link. I
java - Framework
java   Hi this is samapth reddy, iam using struts2 framework. Am not able to understand the Interceptor.what is the use of it and where we use... the brief explanation of this(with example). thnaks and regards sampath reddy
java - Java Interview Questions
java   hi This is sampath reddy, i didnot get the idea i.e some of the elements in integer type of Array,how to find the second highest numnber in that array (condition is using only one loop and with out using
how to access the messagresource.proprties filevalues in normal class file using struts - Struts
{ public static Connection con=null; //pradeep reddy public
converting pdf to ps in mutiple languages - Development process
reddy
Who is father of Artificial Intelligence?
Reddy
Who is father of Artificial Intelligence?
Barbara Liskov Raj Reddy
Andhra Pradesh Tourist Places
and wild life sanctuaries like Kasu Brahmananda Reddy National Park, Mahavir

Ads