TCS Interview Questions.
- What is difference between StringBuffer and StringBuilder? Explain.
- What are the Dependencies Injections in spring framework.
- How do you load properties/resource file using spring.
- Is there any difference between load and get method in Hibernate.
- What is difference between 1st level caching and 2nd level of caching mechanism. How to enable 2nd level of caching?
- How and where do you configure for 2nd level of caching for a specific method. What is eternal .
- How to create a group in Maven
- What do you mean be dependencies in Mavan
- Where do we set Repository Configuration to take for all Jars and what is the preferences.
- Can Maven be used for deployment. If so how?
- How to force Maven to use a Specific type of JVM?
- What are the parameters we use in mvn command.
- What is "With" clause in Oracle
- How do you create Exception in Oracle and use?
- How to select 2nd top salary from Salary Table in Oracle
·What is difference between 1st level caching and 2nd level of caching mechanism? How to enable 2nd level of caching?
|
Sl. No. |
1st Level Caching |
2nd Level Caching |
|
1 |
Hibernate support by default |
Need manual configuration to enable into hibernateConfig.xml. This is done by setting the following property in your hibernate config: <property name="hibernate.cache.use_second_level_cache">true</property> You may also want to turn on the Hibernate query cache. This is done by setting the following property in your hibernate config: <property name="hibernate.cache.use_query_cache">true</property> <property name="hibernate.cache.provider_class"> net.sf.ehcache.hibernate.SingletonEhCacheProvider</property>
|
|
2 |
It cache on session level |
Its cache on session Factory level |
|
3 |
No need any config file |
Need ehcache.xml file to get the list of caching object, tenure and other info. |
· How and where do you configure for 2nd level of caching for a specific method. What is eternal?
Again same thing, we need to configure into hibernateConfig.xml as stated earlier. Eternal is used to maintain memory for cache and session for caching never expire if you set eternal=true.
· How to create a group in Maven
To set a grouping for different packages, we use the <groups/> parameter. Each group will be consist of a <title/> and a <packages/> (as String). The <packages/> element supports wildcard (*) to allow subpackages.
<groups>
<group>
<title>Example 1 - Group Packages</title>
<packages> com.mycompany.myapp:com.mycompany.myapp.package1 </packages>
</group>
</groups>
· What do you mean be dependencies in Maven
This task will check if any of the specified dependencies, and their dependencies are missing or updated, and download them if necessary. The dependencies will be made available as a fileset or path reference.
· Where do we set Repository Configuration to take for all Jars and what is the preference.
Repository Configuration for all jar we do in settings.xml available in Maven directory installed and user’s .m2 folder. Preference is .m2, On unavailability its goes to main maven settings.
· Can Maven be used for deployment? If so how?
Yes it can be. See example
<artifact:deploy file="target/my-project-1.0.jar">
<remoteRepository url="scp://localhost/www/repository"> <authentication username="${repository.username}" privateKey="${user.home}/.ssh/id_dsa"/> </remoteRepository> <pom refid="mypom"/> </artifact:deploy>
· How to force Maven to use a Specific type of JVM?
You can provide class path and jvm information when you run mvn command. Use compiler plugins.
· What are the parameters we use in mvn command?
Whatever parameter we give with mvn command are called plugins. There is a lot of available plugins but some of the common used plugins are
Ø clean
Ø deploy
Ø install
Ø site
Ø ear
Ø ejb
Ø war
Ø jar
Ø eclipse
Ø compiler
Let us know your view tooooooo :)
Thanks,
Dheeraj Bhushan
07845807559
A link for java developer..
http://speedupjavacode.blogspot.com/
--
You received this message because you are subscribed to the Google
Groups "Technical Discussion" group.
To post to this group, send email to
newidea_or...@googlegroups.com
To unsubscribe from this group, send email to
Null Pointer Exception ?
Null Pointer Exception ?
Hi friend,
Today i got few java interesting question. If you could give best answer.
- What is immutable class in java and how to create?
- How do you achieve multiple inheritance in java?
- What are the methods we can use to maintain session.
--
--
You received this message because you are subscribed to the Google
Groups "Technical Discussion" group.
To post to this group, send email to
newidea_or...@googlegroups.com
To unsubscribe from this group, send email to
Seems answer is correct. But I am surprise that why does it happen when I have added final. Neo instead of creating other static method and call; you just remove final from above example. You'll get different output.
My doubt may silly but just want some more clarification about how jvm works.?
Since long time Interview questions has not been updated and I came across some interesting question for core java which is as below. Please put you comment either wrong or right. It will give us more idea and different view.1. in String == is 3 times faster then .equals method, so will it be advisable to use intern method as mention below. Give reason for Yes/NoString a="Hello World";String b=new String("Hello World");if(a==b.intern()){System.out.println("yes contents are equal");}
2. What is SCP (String Constant Pool) and when a String goes to this area. Will this be allowed to collect by GC?
3. What is Eden space and survivor space, tenured generation, permGen and How GC move object from one space to another space.
Eden Space: The pool from which memory is initially allocated for most objects. (Heap Memory)
Survivor Space: The pool containing objects that have survived the garbage collection of the Eden space. (Heap Memory)
Tenured Generation: The pool containing objects that have existed for some time in the survivor space. (Heap Memory)
This automatically explains how objects move from one space to another.
And my favourite ;) PermGen :D
Let me quote an OpenJDK-8 Implementor (dfa)
"Non-heap memory includes a method area shared among all threads and memory required for the internal processing or optimization for the Java VM. It stores per-class structures such as a runtime constant pool, field and method data, and the code for methods and constructors. The method area is logically part of the heap but, depending on the implementation, a Java VM may not garbage collect or compact it. Like the heap memory, the method area may be of a fixed or variable size. The memory for the method area does not need to be contiguous.
Permanent Generation: The pool containing all the reflective data of the virtual machine itself, such as class and method objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas."
I am sure everybody here, would have seen the OutOfMemory:Permgen Space error, ( there is another OutOfMemory: error, ... Java Heap Space) )
Keeping the aforementioned definition of Permanent Generation ( PermGen ) space in mind, we can figure out the reason for it.
----
4. How to increase the size of permGen.
keep updating yourself.more questions are on the way... :)
On Saturday, February 5, 2011 5:35:12 PM UTC+5:30, Shailendra shail wrote:Hi friend,
Today i got few java interesting question. If you could give best answer.
- What is immutable class in java and how to create?
- How do you achieve multiple inheritance in java?
- What are the methods we can use to maintain session.
--
--
You received this message because you are subscribed to the Google
Groups "Technical Discussion" group.
To post to this group, send email to
newidea_or...@googlegroups.com
To unsubscribe from this group, send email to
newidea_or_techn...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/newidea_or_technical?hl=en
---
You received this message because you are subscribed to the Google Groups "Technical Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to newidea_or_techn...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
In the background, something like the following occurs:
int temp = i; // store current value of i
i = i + 1; // increase i because of i++
i = temp; // assign to i
This happens because with i++, first the value of i is evaluated and only then i is increased.
If you change it to ++i you get the following:
i = i + 1; // increment first
int temp = i; // store value of i
i = temp; // asign to i
This is because with ++i, first i is increased and afterwards its value is evaluated.
--
--
You received this message because you are subscribed to the Google
Groups "Technical Discussion" group.
To post to this group, send email to
newidea_or...@googlegroups.com
To unsubscribe from this group, send email to
newidea_or_techn...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/newidea_or_technical?hl=en
---
You received this message because you are subscribed to the Google Groups "Technical Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to newidea_or_techn...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Regards,
NISHANT GUPTA / Master of Computer Applications
8050041001/ ccsC...@gmail.com
-- If you could reason with Religious people, there would be no religion.
i = 6;
System.out.println(i++); //6 (i = 7, prints 6)i = 6;temp = i++
System.out.println(temp); //6 (i = 7, prints 6)
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/newidea_or_technical?hl=en
---
You received this message because you are subscribed to the Google Groups "Technical Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to newidea_or_technical+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the Google
Groups "Technical Discussion" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/newidea_or_technical?hl=en
---
You received this message because you are subscribed to the Google Groups "Technical Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to newidea_or_technical+unsub...@googlegroups.com.
Regards,
NISHANT GUPTA / Master of Computer Applications
8050041001/ ccsC...@gmail.com
-- If you could reason with Religious people, there would be no religion.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/newidea_or_technical?hl=en
---
You received this message because you are subscribed to the Google Groups "Technical Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to newidea_or_techn...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the Google
Groups "Technical Discussion" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/newidea_or_technical?hl=en
---
You received this message because you are subscribed to the Google Groups "Technical Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to newidea_or_techn...@googlegroups.com.
--
--
You received this message because you are subscribed to the Google
Groups "Technical Discussion" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/newidea_or_technical?hl=en
---
You received this message because you are subscribed to the Google Groups "Technical Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to newidea_or_techn...@googlegroups.com.
Regards,
NISHANT GUPTA / Master of Computer Applications
8050041001/ ccsC...@gmail.com
-- If you could reason with Religious people, there would be no religion.
--
--
You received this message because you are subscribed to the Google
Groups "Technical Discussion" group.
To post to this group, send email to
newidea_or...@googlegroups.com
To unsubscribe from this group, send email to
newidea_or_techn...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/newidea_or_technical?hl=en
---
You received this message because you are subscribed to the Google Groups "Technical Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to newidea_or_techn...@googlegroups.com.
--
Regards,
NISHANT GUPTA / Master of Computer Applications
8050041001/ ccsC...@gmail.com
-- If you could reason with Religious people, there would be no religion.
--
package com.shl.algo;
import com.shl.SNGLNode;
public class ReverseSinglyLinkedList { public static void main(String[] args) { SNGLNode root=new SNGLNode(10, new SNGLNode(20, new SNGLNode(2, new SNGLNode(5)))); System.out.println(root);
/* gives incorrect result */ System.out.println(reverse(root)); System.out.println(reverse(reverse(root))); /* gives correct result */ SNGLNode reverse=reverse(root); System.out.println(reverse); System.out.println(reverse(reverse));
}
private static SNGLNode reverse(SNGLNode root) { SNGLNode curr=root; SNGLNode prev=null; SNGLNode next=null; while(curr!=null){ next=curr.next; curr.next=prev; prev=curr; curr=next; } return prev; }}
package com.shl;
public class SNGLNode { int info; public SNGLNode next; public SNGLNode(int info){ this.info=info; } public SNGLNode(int info,SNGLNode next){ his.info=info; this.next=next; } public int getInfo() { return info; } public void setInfo(int info) { this.info = info; } public SNGLNode getNext() { return next; } public void setNext(SNGLNode next) { this.next = next; } @Override public String toString() { return "[" + info + "] -> " + this.next; }}
--
Nice catch ankur.. 👍
Regards,
NISHANT GUPTA / Master of Computer Applications
8050041001/ ccsC...@gmail.com
-- If you could reason with Religious people, there would be no religion.