0% found this document useful (0 votes)
4 views61 pages

Java Interview Questions

The document discusses the differences between form type buttons and submit buttons in HTML, providing examples of each. It also touches on various Java concepts such as string immutability, hashcode collisions, and the differences between Comparable and Comparator. Additionally, it covers topics related to runtime polymorphism and method visibility in Java.

Uploaded by

ranjiwaghela123
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views61 pages

Java Interview Questions

The document discusses the differences between form type buttons and submit buttons in HTML, providing examples of each. It also touches on various Java concepts such as string immutability, hashcode collisions, and the differences between Comparable and Comparator. Additionally, it covers topics related to runtime polymorphism and method visibility in Java.

Uploaded by

ranjiwaghela123
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

What is synchronization?

Difference between form type button and submit.


<!DOCTYPE html>
<html>

<head>
​ <title>Button Example</title>
</head>

<body>
​ <center>
​ ​ <h1 style="color: green;">
​ ​ ​ GeeksforGeeks
​ ​ </h1>
​ ​ <h1>
​ ​ ​ Click the Button
​ ​ </h1>
​ ​ <input type="button"
​ ​ ​ value="Click Me"
​ ​ ​ onclick="showMessage()" />
​ </center>

​ <script>
​ ​ function showMessage() {
​ ​ ​ alert('Hello! You clicked the button.');
​ ​ }
​ </script>
</body>

</html>

<!DOCTYPE html>
<html>

<head>
​ <title>Submit Example</title>
</head>
<body>
​ <h1 style="color: green;">
​ ​ GeeksforGeeks
​ </h1>
​ <h1>Submit the Form</h1>
​ <form action="[Link]
​ ​ method="POST">
​ ​ <label for="username">
​ ​ ​ Username:
​ ​ </label>
​ ​ <input type="text" id="username"
​ ​ ​ name="username" required />
​ ​ <br /><br>
​ ​ <label for="password">
​ ​ ​ Password:
​ ​ </label>
​ ​ <input type="password"
​ ​ ​ id="password"
​ ​ ​ name="password" required />
​ ​ <br /><br>
​ ​ <input type="submit"
​ ​ ​ value="Submit" />
​ </form>
</body>

</html>
[Link]
Here s3 and s2 are false because s3 contains references to Code in string constant pool but s2
contains the heap memory.
If I change s1 rather than it changes in the code it will create new and start pointing it.
So that’s why sting is immutable.
LinkedList

Vector
Stack
HashSet

Linked HashSet

Sorted Set

TreeSet
arrayDeque
HashMap SortedMap

HashTable TreeMap

When any entry it store than it contain some address and that address contain entry
and the linked list indexes are limited so it will store the entry in linked list manner so
that the collision not happen for one hashcode.
Difference between Comparable and Comparator - javatpoint

To avoid hashcode collion which have same when check to equals method but different
hashcode so we have to override hashcode in our class and return unique number.

Shallow equal and deep equal if i have two object which is store two different object
because they are generated using new keyword but the are contain same data so we
can check it by using deep equal by overriding equal in over class.
Can we restrict visibility of derived methods
in Java ?
No, we can not restrict subclass methods. Instead, we can make methods more
accessible than super class methods.

As we Now compile time and run time polymorphism which is


If we make both parent and child as static than than use Animal animal = new
AcquiAnimal() than it will print parent method only.
Jre handle the main method exception
Ki

Smaller one can be adjust with bigger one but if two method are there line two int but i
have int long and long int than it will give me compile time error because compiler get
confuse that which value have to promote.
/****************************19/02/23******************************************/
In comparable it contain only one method which is compareTo and runnable class only
contain one method which is run method

And is any one is false then false, or is any one is true than true and negate method
returns always negative result eg. if true than false and if false than true

andThen first it will double it and then cube it
Compose first it will cube it and then double it

Runtime polymorphism can not work with instance variable of the class.
In that we create variable in parent class and same as in child at the time of runtime
polymorphism the parent instance variable will call .
Dog d = new labDog();
d instance variable will call
labDog() dd = new labDog();
Child class instance var call.
Max in descending order

You might also like