Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

amit


{ City } noida
< Country > india
* Profession *
User No # 39861
Total Questions Posted # 1
Total Answers Posted # 33

Total Answers Posted for My Questions # 2
Total Views for My Questions # 20249

Users Marked my Answers as Correct # 307
Users Marked my Answers as Wrong # 54
Questions / { amit }
Questions Answers Category Views Company eMail

how to get the max salary and name of employee from arraylist without using the Comperator or even Comparable interface?

2 Core Java 20249






Answers / { amit }

Question { TCS, 2912 }

What are blocks?.


Answer

blocks is a group of single and compound statements
between the braces { }
class Amit
{
Amit()
{
Sysem.out.println("constructor");
}
{//begin block instance itializer block

System.out.prinln("amit");

}//end the block

psvm(String [] args)
{

boolean b=true;

if(b)
{//begin block

System.ou.println("boolean");

}//end of block
.
.
.//crete objec in psvm
.

Is This Answer Correct ?    2 Yes 0 No

Question { 3834 }

What are command line arguments?


Answer

ya all people all right
class Amit
{
public static void main(String [] args)
{
for(int i =0;i {
System.ou.println("value" + args[i]);
}
}
javac Amit.java
java Amit asad fgh jkl // value pass through command
value :asad fgh jkl
ami singh amitsing2008@gmail.com

Is This Answer Correct ?    1 Yes 0 No


Question { TCS, 3184 }

What are virtual methods?


Answer

in java all function are virtual.only the function marked
with the final is not virtual.
means to say that if there is any method in super class and
you implemented this method in subclasses too.
then you can invoke on any subcalsses instances refer to
as a superclasses.and the method behaviour will change
according to subcallses instances .
class Amit
{
public void sleep()
{
System.out.println("amit slleping");
}
public static void main(String []args)
{
Amit a = new Amit();
a.sleep();
a = new Subclass1();
a.sleep();
a= new Subclass2();
a.sleep();
}
}

class Subclass1 extends Amit
{
public void sleep()
{
Sysetm.out.println("subclass sleeping");
}
}

class Subclass1 extends Amit
{
public void sleep()
{
System.out.println("subclass 2 sleeping");
}
}
so the output will be
amit sleeping
Subclass1 sleeping
Subclass2 sleeping

so the eat function behave virtualy for the differnt
instance .so this is called the virtual function .so don't
worry every function in java are virtual not the final
function.

Is This Answer Correct ?    4 Yes 0 No

Question { 4694 }

What is a serializable interface?


Answer

ravikiran i think ur are getting wrong
is file is output stream i don't think so please checkit
out then some dont this enormous
without serializatio i will do safe object in outputstream
man think it ,because of ur think of seralization
i know dataoutputstream and objectoutputstream just help to
makeit possible not they are going to save its my pointof
view
without outputstream i will show u save the object in
outpurstream not in a file because u just not going to save
state of particular just going to save object think it
always some bookwriter in not true ha
amitsing2008@gmail.com mca(scjp1.5)an many more so
justthink it

Is This Answer Correct ?    0 Yes 0 No

Question { 3860 }

Explain the relationship between the Canvas and Graphics
class?


Answer

relation between Canvas class and Graphics class is that
trugh paint() method Canvas object provides access to a
Graphics object via its paint()

Is This Answer Correct ?    3 Yes 0 No

Question { TCS, 49947 }

What is the difference between servlet config and servlet
context.


Answer

servlet config is a configuration object used by the
servlet container to pass information to a servlet to a
durimg intialization ,before calling the service method to
a request it calls the init(servlet config) to intialize
the servlet ,at this time it loads all the parameter the
servlet neede, if you need that some parameter only has
relation with the servlet not the whole webapplication you
should to go with servlerconfig ,we use it in
deploymentdescriptor,if you want those information those
you want to use for whole application in which many servlet
so use servletcontext
caution is that :-try to not use servlet context in web
application becaz they are not thread safe
and in deploy ment descritor you use like that:-


............
..........


.............
..........

..........
........

i think u got the right answer ,and best of luck
AMIT SINGH (MCA,NIET,greaternoida) and my email id
amitsing2008@gmail.com for those want more answer related
to java

Is This Answer Correct ?    57 Yes 8 No

Question { BirlaSoft, 52118 }

Find out the 3rd highest salary?


Answer

Empsal table data
700
500
100
900
400
200
600
750


query to find second highest salary from table Empsal

mysql>select distinct(max(e.salary)) from Empsal e
>where e.salary in(
>select e1.salary from Empsal e1 where e1.salary<
(select max(salary) from Empsal));

Output=750



query to find third highest salary from table Empsal


mysql>select distinct(max(e.salary)) from Empsal e
>where e.salary in(
>select e1.salary from Empsal e1 where e1.salary<
>(select max(e1.salary) from Empsal e1
>where e1.salary IN(
>select e2.salary from Empsal e2 where
>e2.salary<(select max(salary) from Empsal))));
Output=700

RUN THE QUERY THEN ARG
amitsing2008@gmail.com(amit is back)

Is This Answer Correct ?    2 Yes 0 No

Question { Hewitt, 106438 }

find out the third highest salary?


Answer

forget the book first
Empsal table data
700
500
100
900
400
200
600
750


query to find second highest salary from table Empsal

mysql>select distinct(max(e.salary)) from Empsal e
>where e.salary in(
>select e1.salary from Empsal e1 where e1.salary<(select max(salary) from Empsal));

Output=750



query to find third highest salary from table Empsal


mysql>select distinct(max(e.salary)) from Empsal e
>where e.salary in(
>select e1.salary from Empsal e1 where e1.salary<
>(select max(e1.salary) from Empsal e1
>where e1.salary IN(
>select e2.salary from Empsal e2 where
>e2.salary<(select max(salary) from Empsal))));
Output=700
don't args without run
amitsing2008@gmail.com(amy is back again)

Is This Answer Correct ?    3 Yes 5 No

Question { Ordain Solutions, 8996 }

How does serialization work


Answer

serializtion just to serialize a obect of a particular
class mean to say that
its just to save the state of object of particular clas
how imagine

SERIALIZATION:
a class Xyz
this class implements the Serializable interface
then you provide some state to create its object
and want that its state will remain safe
so what you should to do
you are using a
"FileOutputstream" to create a
than a "ObjectOutputStream" And then use writeObject() mehod
to write it in file

FileOutputStream f1 = new FileOutputStream("f1.txt");
ObjectOutputStream o1 = new ObjectOutStream(f1);
o1.writeObject(refreance variable of particular class)


then what happen the state of the particular object or
means some value which you gave its instance variable
or whole object will convert in a byte and store in file
.its a serializtion

DESERIALIZATION:
so the constructor first time will execute during the
creation time.
but when you desrialize constructor will not execute
because of the serializable interface so
when you want to read the state or any value which you gave
at the time of the serializtion will comeup as it is

FileInputStream f2 = new FileInputStream("f1.txt");
ObjectInputStream f3 = new ObjectInputStream(f2);
f3.readObject();//return type object type so cast it

and youwill get the same state of object which you will
make at the time of searlization.

"so the searliztion is just to saving the object in a form
of byte in a storage medium or write it in file using the
i/o
and then deserialize is convert the byte in to a particular
object with the same state when the object created"
i want to see you some code :

class Amit implements Serializable
{
String name;
int age;
Amit(Strin name,int age)
{
this.name = name;
this.age = age;
}
public Strin toString()
{
return "name =" + name +";+ age =" + age;
}
}

class Xyz
{
publc static void main(string []args)
{
Amit a = new Amit("amit",26);
//serialization
try{
FileOutputStram f1 = new FileOutputream("file.txt");
ObjectOutputStream o1 = new ObjectOutputStream(f1);
o1.writeObject(a);
o1.close();
}
catch(Excetion e)
{
}
//desrialization
try{
FileInputStream f2 = new FileInputStream("file.txt");
ObjectInputStream o2 = new ObjectInputStream(f2);
Amit a1 = o2.writeObject(a);
System.out.println("value" + a1);
System.out.println("value" + a1.toString());
}
catch(Exception e)
{
}
}
thanks Amit singh
amitsin2008@gmail.com amit09mca
}
//sorry :-import the io package too

Is This Answer Correct ?    1 Yes 2 No

Question { Saka Solutions, 2174 }

whats is mean by object and class?


Answer

hello dear
class is just a prototype and define the characterstics of
thing and the object is the instance of classs
amit singh
amitsing2008@gmail.com

Is This Answer Correct ?    4 Yes 1 No

Question { TCS, 56063 }

can you create interface instance ?


Answer

it was just a bullshit you did man
you are creating jus he anonymmous class and is just treate
a subclass of the paricular inerface and also the override
mehod execute
learn java because prople like you just amajed those people
those don' know java
so try your self first thing that java is the whole thing
which realed to Object class not he object so learn it

Is This Answer Correct ?    0 Yes 0 No

Question { Yardi, 279057 }

how to find the second highest salary from emp table?


Answer

forget the book

Empsal table data
700
500
100
900
400
200
600
750


query to find second highest salary from table Empsal

mysql>select distinct(max(e.salary)) from Empsal e
>where e.salary in(
>select e1.salary from Empsal e1 where e1.salary<(select max(salary) from Empsal));

Output=750



query to find third highest salary from table Empsal


mysql>select distinct(max(e.salary)) from Empsal e
>where e.salary in(
>select e1.salary from Empsal e1 where e1.salary<
>(select max(e1.salary) from Empsal e1
>where e1.salary IN(
>select e2.salary from Empsal e2 where
>e2.salary<(select max(salary) from Empsal))));
Output=700

RUN THE QUERY THEN ARG
amitsing2008@gmail.com(amit is back on this site)

Is This Answer Correct ?    3 Yes 0 No

Question { HCL, 5384 }

what does batchUpdate does?


Answer

batch update calls to database as chunk(group),
if you want to run more then one sql statement in a single
database call then you have to go for it

Is This Answer Correct ?    3 Yes 1 No

Question { Wipro, 23108 }

why Runnable interface is preferable than extending the
Thread class?


Answer

is this prefable why simple
you class A extends other class B
and it also want to be a thread then what you should
beacuse its allow in java that one class extends two class
its not possible in java
class A
{
}
class B extends A
{
}
then what to do to make the thread of class B
so you are going to extends the Thread class too
its biggest blunder in java so you should to prefer
implements the Runnable interface
that it not just the f--k above mention though my ther frnds
thanks imagie
class B extends A implements Runnable
{
public void run()
{
}

}
class C
{
public static void main(String []args)
{
C c = new C();
B b = new B();
Thread t1 = new Thread(b);
t1.start();
}
}
}
and another reason to implements the Runnable interface
when you want to allocate some specific work means to say
that you just whe the thead will create and run ,through the
run method which you define in this class do some
when the thread runs means to say that when you extends
Thread and you not define the run method the default will
run
and when you implements the Runnable you must and needs to
define it do some functionaklity on each thread creation
thanks amitsing2008@gmail.com
amit09mca

Is This Answer Correct ?    11 Yes 3 No

Question { 6548 }

How will you override default serialization mechanism in java


Answer

you can inplements the Serialization interface for those
class you want to serailize
its marker interface its haven't any behaviour
but it indiacte that particular class is serializable
you can read and write particular object to convert in a
byte.
class Amit implements Serializable
{
Amit()
{
}
}
class B
{
public static void main(String []args)
{
Amit a = new Amit();
try{

}
catch{IoExcepton e)
{
}
try{
FileIntputStream f = new FileIntputStream("apoorva.txt")
OjectIntputStream o = new ObhjctInputStream(f);
o.ReadObject();
}
catch(IoException e)
{
}
}
thanks amit singh
amitsing2008@gmail.com

Is This Answer Correct ?    0 Yes 1 No

 [1]   2   3    Next