Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Can a class in java be private, if yes what are implementations of it?

This is a discussion on Can a class in java be private, if yes what are implementations of it? within the Java forums, part of the Software Development category; Can a class in java be private, if yes what are implementations of it?...

Go Back   Geeks Talk > Software Development > Java
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Java Java related Issues and Problems

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-16-2007
Junior Member
 
Join Date: Oct 2007
Location: Pune, India
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
prsaraf is on a distinguished road
Question Can a class in java be private, if yes what are implementations of it?

Can a class in java be private, if yes what are implementations of it?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-16-2007
Contributing Member
 
Join Date: Sep 2006
Location: India
Posts: 39
Thanks: 2
Thanked 11 Times in 10 Posts
SahilKabra is on a distinguished road
Re: Can a class in java be private, if yes what are implementations of it?

A normal class in Java cannot be private, but an inner class can be private. Inner classes are generally used in Swings to add listeners for various components.


Regards,
Sahil.
Reply With Quote
  #3 (permalink)  
Old 11-19-2007
Junior Member
 
Join Date: Oct 2007
Location: Hyderabad
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
prasannaramudu is on a distinguished road
Re: Can a class in java be private, if yes what are implementations of it?

we can't declare top level class as private(only public).we can declare inner classes as private.if declare any methods and variable declared in private class we can access those methods and variable with in that scope directly.if u want access out of that class by using constructor we can access.
Reply With Quote
  #4 (permalink)  
Old 11-23-2007
Junior Member
 
Join Date: Jun 2007
Location: Gurgaon
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
gaurav0252 is on a distinguished road
Re: Can a class in java be private, if yes what are implementations of it?

No top level class in java can't be declared as private only public, abstract and final are permitted.
Reply With Quote
  #5 (permalink)  
Old 12-06-2007
Junior Member
 
Join Date: Dec 2007
Location: chennai
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
redbhuvanes is on a distinguished road
Thumbs up Re: Can a class in java be private, if yes what are implementations of it?

Java Inner Classes
class A {
private a;
class B {
private b;
void f() {
b = a+a; // accessing pvt. var of A
}
public g(){
B myObj = new B();
myObj.f();
int x = myObj.b; // accessing pvt. var
of A
}
}
Reply With Quote
Reply

  Geeks Talk > Software Development > Java

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Inherit private members of base class rahul.gupta C and C++ 10 09-24-2008 09:15 AM
How to inherit class in Java progamming Geek_Guest Java 1 07-23-2007 05:30 AM
Private Forums for Privileged Members admin Site News & Announcements 3 01-04-2007 11:45 AM
Private Forum for Contributors and Moderators admin Site News & Announcements 3 06-17-2006 07:38 AM


All times are GMT -4. The time now is 10:59 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved