Abhishek KumarSoni

Ranch Hand
+ Follow
since Nov 05, 2013
Merit badge: grant badges
Biography
I am a final year student in B.Tech from Computer Science and Engineering.I want to be a software engineer in my life....
For More
Sisrsa
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Abhishek KumarSoni

Hello friends.......i was trying socket programming code in which i found unexpected behaviour as follow:
This was my server code

And this is client code


I execute server code and after that client code
output printed was -> my port is 52340 .
Why this unexpected behaviour??It should be -> my port is 4001?

Bear Bibeault wrote:P.S. In a JSP you would use <c:url>, not Java code,


Its mean most of the website like google or microsoft encodes their URL because they work on global level where people may have disable their cookies
I pick this code from Head first Java

but just a Jframe is appearing no Jpanel no green color circle??What is wrong with code
10 years ago
During my reading of session management from Head First JSP & Servlet I found that there are two ways of session management.One is By help of cookies In case If client has not enabled it then URL rewriting is substitute.It means that while developing a web app we should encode each and every link.Because we at time of development even after development we are not aware of fact that whether our client will enable cookie or not So as alternate we should encode each link by
using <code>response.encodeURL()</code>
method .Is this true?
Recently I was reading Head First JSP where it was explained that servlet Context attribute are not thread safe.I understood the concept.then it was also explained that how to make it thread safe.In which one solution given was to make service() method synchronized.but writer rejects this option saying that if we make service method synchronized it would stop other thread from same servlet accessing the context attributes,but it will not do anything to stop a thread from completly different servlet..Here friends its ok that it cccan not stop thread from other servlet but why it will not stop thread for same servlet.It mean that thread for same servlet are based on same object thats why they conflict each other.
Hello friends
Could someone please explain me what is the need of init method in a servlet life cycle .We use constructor to load the class and init() function to initialize it(for task like DB connectivity).. why we need init a method separately for initializing a servlet.why constructor can not be used to initialize a servlet.
According to me this function is not properly designed and output is useless outpur should be 456789 not [4,5,6,7,8,9].I could use this in parseInt function or everywhere a string object is required


Here output at line 6 is [4,5,6,7,8,9] .What kind of String is this??
Why exception arises at next line.

Following line is giving you constructor error

In your code there is no such constructor which takes no parameter as argument.Since you have declared your own constructor so compiler is not going to provide you a default constructor.If you still want you have to mention it in your code manually as follow

Now since you have a no arg constructor your code runs.

Gob Bluth wrote:
Is everything from the constructor down (in the class) and Shirt.oneShirt (in the main) just a waste of time?


We can not say it a waste of memory.It all depends on usage of your program. Let us take your code.
In your code you will initialize your Shirt variable as follow

Now after initializing this you want to change your Shirt's collarSize then setCollarSize will be helpful to set collarSize for this particular instance of Shirt.

Although in your code you can change it directly

but this is right untill you are in same package outside the package you have to use setters since your instance variable are of default access.
This was all about set method Second let us take getter of this code.
Getter in a class can never be a waste of memory.Because getters provide you encapsulation.In your code instance variable are default so their's value can be accessed directly in same package as follow

But If you want to access your collarSize outside the package than you cant access it as follow

It will report an error because collarSize is of default access and is not accessible outside the package.
Then getter will retrieve this value for you as follow

One case if your declare all of your instance variable as public then we can say getters are just wasted of time.but in that case your code will not remain encapsulate.So declare all the instance variable as private and provide getters for their access outside class.
10 years ago
Hello friends
i was performing a c program today which was as follow
Reason for this unexpected behaviour was given that in c a single variable can change its value only once within a single sequence point.
But if I run this program as a java program output will be 21 and 110.mean expected value.
So friends just wanted to confirm does java also have such kind of concept if yes than what are sequence point in Java.Are they same as c's sequence point.

R. Jain wrote:Please don't edit your answer after you've posted it. Not at least after 10 minutes. It makes the following answer absurd, like it did just now.


I will take care for it in furure, sir and thanks a lot for your response to my query.But actually in whiz lab output at line number was printed as false and reason being given was any comparison related to NaN results in false.except != which always results in true.so it means explanation was wrong at whizlab?
I found following question in whizlab and have a doubt related this

Here can someone explain me what is this NaN .if I print value of f then it will display NaN.what is its meaning and why line number 3 comes out to be true while other are false .Also in whizlab it was written that all comparison related to NaN always results in false except for "!=" operator.It was said that != will always result in true and all other ==,<=,>= results in false.but when i run this program == comes out to be true . Is this NaN is present in all wrapper class.

Hello friends Here line number is showing expected output which is 828 .But friend why output in line number 11 is ceene-abhi .It should follow rule followed in line number 10 and output should be -abhiceene().I mean -abhi should be calculated first thrn ceene should be added in it.

Myke Enriq wrote:I am glad that you did not hurry and made the right choice. In the end the goal is to learn as much Java as possible, not a diploma.

As for last week advice, I am not qualified to give any, as at the moment I am studying myself for this exam.
Having said that, one good thing that I did for the OCA exam was to solve the enthuware mock exams in the week before the exam, so that I remembered the questions and answers.
Plus I had read the SCJP 6 K&B book twice before I took the exam.

Could you please tell us what books have you used to study for OCP ?


Sir i have read k&b book twice and some topic thrice also .I have tried mock exam on examlab (average 60%) certpal(average 72%) and two exam of whizlab(diagnostic 86% test1 72% ).and 5 test in whizlab is still pending

R. Jain wrote:

Abhishek KumarSoni wrote:On my part the reason of compilation fail will be due to generic variable Integer.But i want to ask why?


Yeah you're right. It's due to that. Why? Ok, think of when is the instanceof check done - a). At compile time, b). At runtime.
Once you understand this, then go back and see your previous question. Try to relate the answer there, and the reason you just posted. You'll get the answer.


Sir with previous three question and your answer helps me a lot.thanks a lot for your respons to my query.
Generic is the part where i am hurted a lot.This is my week area.
Could you please explain me one more thing whar is difference between a wildcart<?> and a type parameter