Java objective type questions and answers on static keyword



6.What is the output of below program ?

java multiple choice questions with answers

x=10 x=10
x=10 x=20
x=30 x=30
x=30 x=20




Java mcq with answers on this keyword




Core java multiple choice questions with answers on method overloading




Java mutliple choice questions with answers on constructors

  • On the request of many friends we added java multiple questions with answers.
  • Java mcq questions with answers on constructors.
  • We will add all java topics multiple questions with answers for freshers and experienced.



How to get java source files from jar file

  • Jar : Java Archive is a group of .class files.
  • We can create a jar file using following commands
  • jar -cvf  example.jar test.class
  • jar -cvf example.jar *.*
  • To unzip from jar file we need to use following command.
  • jar -xvf  instanceofjava.jar



How to get source code from jar file using java De-compilers

how to get source code from jar file in eclipse


  • Open JD-GUI and File -> open -> open target jar file.
  • It will show java source code.

How to extract java files from jar in eclipse

  •  We can get java source files from jar file by using eclipse also for this we need to add a plugin.
  • Download jar file from http://jd.benow.ca/
  • Unzip it . you will get jd.ide.eclipse.plugin_1.0.0.jar file  and add it to eclipse plugin folder.
  • And restart your eclipse.
  • Add target jar file to a project and now click on the file you will get source code.
  • You can add target jar file using java project->java buildpath -> add external jars option


how to convert jar to java source in eclipse


  • Here i added jstl core jar to eclipse to see java source files.
  • Click on the file now it will show source code 
  • How to extract java files from jar

how to extract java files from jar in eclipse

Hibernate Native sql query with example

  • By Using Hibernate Native SQL we can write database dependent queries as part of hibernate.
  • Hibernate Native Sql allows us to write create , update,  delete and insert queries.
  • We can also call Stored procedures using Hibernate Native Sql.
  • When the query is too complex using HQL then we need to use hibernate sql query.
  • Hibernate uses the org.hibernate.SQLQuery interface for native SQL
    1. SQLQuery is a sub interface of Query
    2. Use createSQLQuery() factory method on Session to create SQLQuery object.
  •  Hibernate SQLQuery must be associated with an existing Hibernate entity or scalar result.



Hibernate native sql insert query example

  1. Session session = sessionFactory.openSession();
  2. session.beginTransaction();
  3.  
  4. SQLQuery insertsqlQuery = session.createSQLQuery("INSERT INTO
  5. Physician(firstname,lastname,fee,hospital)VALUES(?,?,?,?)");
  6.  
  7.  insertsqlQuery.setParameter(0, "Saidesh");
  8.  insertsqlQuery.setParameter(1, "Kilaru");
  9.  insertsqlQuery.setParameter(2, 50); 
  10.  insertsqlQuery.setParameter(3, "Yashoda");        
  11.  insertsqlQuery.executeUpdate();

 Hibernate scalar query example

  • Writing a Hibernate Sql query to get list of  scalars or values from single or multiple tables.
  • Lets see an example on Hibernate scalar query.


  1. String hibernate_sql = "SELECT first_name, fee FROM  Physician";
  2. SQLQuery query = session.createSQLQuery(hibernate_sql);
  3. query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
  4. List results = query.list();

 Hibernate named sql Queries

  • Writing a Hibernate Sql query to get entity object by using addEntity() method.
  • Lets see an example on Hibernate named sql query

hibernate native sql query parameters scalar


Select Menu