Powered by Blogger.
Showing posts with label Interview Questions. Show all posts
Showing posts with label Interview Questions. Show all posts

Best practice to find Duplicate Character from a String in java

>> Sunday, June 28, 2015

This program could be the best way to find the number of duplicate characters from the given String. Here we are using Map and Set from java.util.Collections package. In the below program we are using Set to collect different characters from the given String. One boolean variable and one method named as findDuplicateChar(String myString) to find the duplicates. Also some known methods like toCharArray() to convert String to character array and for-each loop to iterate Set and Array. Better you can go through the given program to find duplicate characters from the given String.
Find duplicate characters program_JavabynataraJ

Read more..

Why public static void main(String args[])

>> Thursday, May 1, 2014

In most of the java interviews either for freshers or experience guys frequently facing this question. This will be easy when you have full idea about access specifiers and modifiers in java. Lets discuss about our mantra
public static void main(String args[]).
why public static void main in java_JavabynataraJ
What is the Importance of the public static void main(String args[ ])
Whether a class contains main( ) or not and whether the main( ) is declared based on  requirement, these all are things are won't be checked by compiler,these things are checked by JVM at Runtime.

Read more..

Java program to print word for the given number

>> Saturday, October 8, 2011

Converting a number to characters or to words as readable format in text will be done easily using arrays in java. Based on the given number we can write our logic. But here i am taking the number below to 10000. So we can complete our program easily. But sure, you will understand the logic. It is simple.using Fibonacci logic , using modulo operator and divider operator we can completer our program. This is important interview question and some of like, Reverse an array, matrix addition, matrix multiplication using arrays and prime number logic these are important for the java interviews.
Convert number to Word or Characters_JavabynataraJ
In this program we have to create two arrays one is ones array with the words of one,two,three.....nineteen. Then create another array with tens array contains ten,twenty,.....ninety.
Then write the given logic to convert a number into character.

Read more..

Hibernate Interview Questions and Answers - 5

>> Saturday, June 18, 2011

41) What is the difference between sorted and ordered collection in hibernate?


A) sorted collection vs. order collection
sorted collection :-
A sorted collection is sorting a collection by utilizing the sorting features provided by the Java collections framework. The sorting occurs in the memory of JVM which running Hibernate, after the data being read from database using java comparator.
If your collection is not large, it will be more efficient way to sort it.
order collection :-
Order collection is sorting a collection by specifying the order-by clause for sorting this collection when retrieval.
If your collection is very large, it will be more efficient way to sort it .

Read more..

Hibernate Interview Questions and Answers - 4

>> Friday, June 17, 2011

31) What does it mean to be inverse?

A) It informs hibernate to ignore that end of the relationship. If the one–to–many was marked as inverse, hibernate would create a child–>parent relationship (child.getParent).

32) What do you mean by Named – SQL query?

A) Named SQL queries are defined in the mapping xml document and called wherever required.

Example:

SELECT emp.EMP_ID AS {emp.empid},
emp.EMP_ADDRESS AS {emp.address},
emp.EMP_NAME AS {emp.name}
FROM Employee EMP WHERE emp.NAME LIKE :name

Invoke Named Query :
List people = session.getNamedQuery(“empdetails”).setString(“TomBrady”, name).setMaxResults(50).list();

Read more..

Hibernate Interview Questions and Answers - 3

>> Thursday, June 16, 2011

21) What role does the Session interface play in Hibernate?

A) The Session interface is the primary interface used by Hibernate applications. It is a single-threaded, short-lived object representing a conversation between the application and the persistent store. It allows you to create query objects to retrieve persistent objects.

Session session = sessionFactory.openSession( );

Session interface role:
* Wraps a JDBC connection
* Factory for Transaction
* Holds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier

Read more..

Hibernate Interview Questions and Answers - 2

>> Wednesday, June 15, 2011

11) Explain about mapping files in Hibernate?

Mapping files forms the core of any database mapping tools. These files contain field to field mapping, usually this mapping occurs between classes and attributes. After mapping files they can be persist to the database. Tags can be used to indicate the presence of a primary key.

12) What is the effect when a transient mapped object is passed onto a Sessions save?


When a session.save( ) is passed to a transient mapped object it makes the method to become more persistent. Garbage collection and termination of the Java virtual machine stays as long as it is deleted explicitly. It may head back to its transient state.

13) Explain about version field?

Application level data integrity constants are important if you are making changes to offline information which is again backed by database. Higher level locking or versioning protocol is required to support them. Version field usage comes at this stage but the design and implementation process is left to the developer.

Read more..

Hibernate Interview Questions and Answers - 1

>> Tuesday, June 14, 2011

1) Explain about Hibernate?
Hibernate Interview Questions_JavabynataraJ
Hibernate solves problems such as Object Relational impedance mismatch, etc. It is commonly used for object and query service. It helps data base developers develop classes which include inheritance, association, composition and polymorphism. A developer or user can express queries either in HQL or SQL.

2) Explain about the primary feature of Hibernate?

Primary feature of hibernate is to java classes to database tables. Data query and retrieval is also possible with Hibernate. Application portability is a key feature in Hibernate it allows developers to port applications to almost all SQL databases.

Read more..

Collections KeyPoints

>> Thursday, May 19, 2011

The Main Collections KeyPoints in java

Collection is a group of objects.  java.util package provides important types of collections. There are two fundamental types of collections they are Collection and Map. Collection types hold a group of objects, Eg. Lists and Sets where as Map types hold group of objects as key, value pairs.
Eg. Hashtable, HashMap, TreeMap, and LinkedHashMap (LinkedList+HashTable). Explained in detail in last post, how to iterate HashMap.
Here the collections of classes and interfaces having some their own properties.They are


Read more..

Java Interview Questions on Package and Interface

>> Wednesday, September 29, 2010

Interview Questions on Package and interface in Java

1) What are packages ? What is use of packages ?

Ans :The package statement defines a name space in which classes are stored.If you omit the package, the classes are put into the default package.
Signature... package pkg;
Use: * It specifies to which package the classes defined in a file belongs to. * Package is both naming and a visibility control mechanism.

2) What is difference between importing "java.applet.Applet" and "java.applet.*;" ?

Ans :"java.applet.Applet" will import only the class Applet from the package java.applet
Where as "java.applet.*" will import all the classes from java.applet package.

3) What do you understand by package access specifier?

Ans : public: Anything declared as public can be accessed from anywhere
private: Anything declared in the private can’t be seen outside of its class.
default: It is visible to subclasses as well as to other classes in the same package.

4) What is interface? What is use of interface?

Ans : It is similar to class which may contain method’s signature only but not bodies.
Methods declared in interface are abstract methods. We can implement many interfaces on a class which support the multiple inheritance.

5) Is it is necessary to implement all methods in an interface?

Ans : Yes. All the methods have to be implemented.

6) Which is the default access modifier for an interface method?

Ans : public.

7) Can we define a variable in an interface ?and what type it should be ?

Ans : Yes we can define a variable in an interface. They are implicitly final and static.

8) What is difference between interface and an abstract class?

Ans : All the methods declared inside an Interface are abstract. Where as abstract class must have at least one abstract method and others may be concrete or abstract.
In Interface we need not use the keyword abstract for the methods.

9) By default, all program import the java.lang package.

True/False

Ans : True

10) Java compiler stores the .class files in the path specified in CLASSPATH environmental variable.

True/False

Ans : False


11) User-defined package can also be imported just like the standard packages.

True/False

Ans : True

12) When a program does not want to handle exception, the ______class is used.

Ans : Throws

13) The main subclass of the Exception class is _______ class.

Ans : RuntimeException

14) Only subclasses of ______class may be caught or thrown.

Ans : Throwable

15) Any user-defined exception class is a subclass of the _____ class.

Ans : Exception

16) The catch clause of the user-defined exception class should ______ its Base class catch clause.

Ans : Exception

17) A _______ is used to separate the hierarchy of the class while declaring an Import statement.

Ans : Package

18) All standard classes of Java are included within a package called _____.
Ans : java.lang

19) All the classes in a package can be simultaneously imported using ____.

Ans : *

20) Can you define a variable inside an Interface. If no, why? If yes, how?

Ans.: YES. final and static

21) How many concrete classes can you have inside an interface?

Ans.: None

22) Can you extend an interface?

Ans.: Yes

23) Is it necessary to implement all the methods of an interface while implementing the interface?

Ans.: No

24) If you do not implement all the methods of an interface while implementing , what specifier should you use for the class ?

Ans.: abstract

25) How do you achieve multiple inheritance in Java?

Ans: Using interfaces.

26) How to declare an interface example?

Ans : access class classname implements interface.

27) Can you achieve multiple interface through interface?

a)True
b) false

Ans : a.

28) Can variables be declared in an interface ? If so, what are the modifiers?

Ans : Yes. final and static are the modifiers can be declared in an interface.

29) What are the possible access modifiers when implementing interface methods?

Ans : public.

30) Can anonymous classes be implemented an interface?

Ans : Yes.

31) Interfaces can’t be extended.

a)True

b)False

Ans : b.

32) Is it possible to use few methods of an interface in a class ? If so, how?

Ans : Yes. Declare the class as abstract.

Read more..

Java Interview Questions by Nageswara Rao

>> Friday, September 10, 2010

The famous java lecturer Nageswara Rao from InetSolv Ameerpeta, Hyderabad has written java interview Questions. Also he written several books on Core Java and J2EE technologies.
You may be an experienced Java developer with hand on experience in core development or you may be a fresher who is looking for an entry in java job market, if you want to hit the job market , you may need to refresh some of the basic java terms or you may need to know what are the commonly asked questions to prepare yourself to for java technical interview.
Java interview Questions-JavabynataraJYou as an experienced java developer, just need to refresh your knowledge on java. But you as a fresher may need to know what can be the possible questions , what are the commonly asked questions, what are the valid answers for these questions and so on.

Read more..

164 Java Interview Questions by Nageswara Rao

>> Friday, August 14, 2009

Dr.R.Nageswara Rao has given some of the Java interview questions in his Core Java Integrated Approach book. These are the questions frequently asked in Java interviews.Go throught these Questions this would be helpful to you..
164 Core Java Interview Questions by Nageswara Rao_JavabynataraJ
If you are already attended any interviews on java you might have faced most of the questions given below. Please leave a comment if you have any queries.

Read more..

Struts Flow and Architecture

>> Saturday, June 6, 2009

Before going to know about Struts Flow and Architecture we get to know What is Struts Frame work? As per simple definition "Struts is an open Source framework, given by Apache Software Foundation, which is used develop MVC2 based web applications in java". Struts contains Validations, I18N(Internationalization and Exception handling features. Because of these three Struts became very popular.

Web.xml entries will be read by WebContainer of WebServer or Application Server software. Struts configuration file entry is will be read by ActionServlet.

WebContainer creates Actionservlet object where as FormBean class object, ActionClass object will be created by ActionServlet.
Struts Flow and Architecture_001

Read more..

Related Posts Plugin for WordPress, Blogger...
© javabynataraj.blogspot.com from 2009 - 2022. All rights reserved.