Java Queries Here..

bijay_ps

Broken In
public class Test{

//1. Test obj1=new Test();

Test(){}

public static void main(String[] args){

//2. Test obj2=new Test();
}
}

In this prgm if U'll write either only the stmnt 1 or stmnt 2 (those whic I have commented and mentioned as 1 and 2) then it'll work fine no compilation error n no runtime error. BUT IF U'll WRITE BOTH OF THEM THEN ITS A RUNTIME ERROR.
Now don't ask me whats the error just see for Urself. I jst wanna knw wats the rsn for this?
 

RBX

In the zone
I have a class LinkedList (members: data, next, and a lot of methods). I want to implement a Stack class as an extension to LinkedList but actually with much limited functionality; I can't reduce the visibility of the methods I don't want, what can be done to make them inaccessible ?

Also, what should be the visibility of data, next in LinkedList ? I currently have them private, but want them to be inherited by subclasses, and don't want the data, and next to be modified by a class using a LinkedList object only by the public methods provided. I am looking at the protected modifier, with the possibility that LinkedList may be extended in other packages, but since I can't reduce the visibility of a member by inheriting it, if a class in other package extends it, the members remain protected in it too, and the members will be freely accessible through the whole package ?

I'd also like to talk about the assumptions made here, correct me if I'm wrong. I am developing this package, so all the classes (LinkedList, Stack etc.) will be developed by me, or are there ways someone else could extend the package ?

I have more things to ask, but it seems I'm too confused right now, it would be great if someone also posts a link with examples on inter-package inheritance, displaying how an object's members are accessed by subclass of its class, and other classes that are not the subclasses of that object's class.

EDIT:
After doing some tests, here are my results *i.imgur.com/19uQkCw.png
(Directed links denote parent to child relationship, green = visible, red = not visible)
What would be the visibility of 'b' in class E ? It can be inherited by F, but not used in F - that makes it neither of default, private, protected.
 
Last edited:

ariftwister

Truth Seeker
Friends I need your help to write a java program. It's okay, If you could provide me code/logic to this problem.
" A group of character is get from user and stored in an array. Another variable "distance" is also get from user. Now if the distance is 3, then each of the character is changed to its next 3rd letter.
For example a->d,b->e,c->f.....w->z,x->a,y->b,z->c.
Can you help me guys?
 

abhidev

Human Spambot
Friends I need your help to write a java program. It's okay, If you could provide me code/logic to this problem.
" A group of character is get from user and stored in an array. Another variable "distance" is also get from user. Now if the distance is 3, then each of the character is changed to its next 3rd letter.
For example a->d,b->e,c->f.....w->z,x->a,y->b,z->c.
Can you help me guys?

Use the ASCII values to find the characters based on the distance as @harshil said
 

ariftwister

Truth Seeker
Guys.. Got it.. Thanks for your help !!

for(i=0;i90)
a=a-26;
}
Edit: Nope the above code isn't right.
Actual code contains type conversion
 
Last edited:

abhidev

Human Spambot
This is a java queries section and not Javascript... There must be a different thread for Javascript queries :)
 

Piyush

Lanaya
Hi I am creating a file upload and download form via JSP. Its all working fine, I can upload small files, can create and fetch download for that particular file and delete the file if required. Now the problem is, suppose 2 users are using my app. User A uploaded a file named file.txt. Sometime later User B also uploaded the file named file.txt. Now the previous file will get overwrite. I dont want a popup box which will alert the User B that a file of that name already exists. Instead I want a folder to be created for each user so that they have their files stored on server side in their named folder.
Code:
saveFile="C:/temp/"+saveFile;
I need to modify this line of code I think.
 

vickybat

I am the night...I am...
@piyush

So did you manage to do the xml part for uploading and downloading? I posted about that in the html/javascript thread.

About this one, how will you distinguish users? You can't distinguish users unless you support login.
For this one, you need sessions. Like i said, you need to do some reading on these.

Sessions allow a particular instance of server, to recognize a particular client/browser request. This is achieved through "Cookies" or "URL Rewriting".

So for a particular session, you can prompt the user to create a directory where their respective files go.

I don't know, but i think there should be a respective file server for this. What exactly you are developing?
From the looks of this, i figure its an end to end J2EE project than simple web front end designing.
 
Top Bottom