How To Create Nested Class in java

InnerClass class A {             class B {                         public void print() {                                     System.out.println(“HI “);                         }             } } public class InnerClasses {             public static void main(String[] args) {                         A aObj=new A();                                                 A.B bObj=aObj.new B();                                                             bObj.print();                        } }  Inner Class2 class AOuter {             class BInner {                         public void printMe()…

Read More Read More

Difference between TRUNCATE, DELETE and DROP commands

TRUNCATE is a Data Definition Language command whereas DELETE is a Data M anipulatio Language command.  When compared with delete TRUNCATE is very fast. Because Step 1:When you perform DELETE all  data in table gets copied first in the  Tablespace with name Rollback.first  Then delete operation get performed. Benefit of delete is  after deleting the content of table if you try…

Read More Read More

Tricky Facts About views

Restrictions on Updating Data Through Views You can insert, update, and delete rows in a view, subject to the following limitations: Cool Gadgets If the view contains joins between multiple tables you can only insert and update one table in the view, and you can’t delete rows. You can’t directly modify data in views based on union queries. You can’t modify…

Read More Read More

Tricky Sql Interview Questions

Sql Mostly used queries. 1.Views CREATE OR REPLACE VIEW passStudent ASSELECT StudentId,StudentNameFROM StudentWHERE result=pass 2.GroupBy ClauseStudent Tablecreate table student(studId number(5),studName varchar2(10),marks number(3));   insert into student values(1,’sur’,30);    insert into student values(2,’jit’,65);  alter table student add(collegeId number(3)); SQL> update student set collegeId=1 where studId=1;    SQL> update student set collegeId=2 where studId=2;  SQL> insert into student values(3,’ramesh’,45,1);    Question select collegeId,count(collegeId) from student group by collegeId;                           COLLEGEID COUNT(COLLEGEID)                                              …

Read More Read More

When to use comparator and when we should use comparable.

When to use comparator and when we should use comparable. Use Comparable if you want to define a default (natural) ordering behaviour of the object in question, a common practice is to use a technical or natural (database?) identifier of the object for this. Use Comparator if you want to define an external controllable ordering behaviour, this can override the…

Read More Read More

Array Declaration in java :)

  I am gonna discuss about various possibilities in which array can be declared. String[] empNames []; Correct String[][][] professions; // Correct int[5] salaries;//Wrong Remember JVM wont allocate size until oyu create objects. HOw to create the array of type String. int[] items; // Declares the array of ints items= new int[4]; // constructs an array and assigns it //…

Read More Read More

RequestDispatcher.forward() vs HttpServletResponse.sendRedirect()

Get Free Book 🙂 RequestDispatcher.forward() vs HttpServletResponse.sendRedirect()_______________________________________________________________RequestDispatcher.forward()_______________________________________________________________ 1.When we use forward method, request is transfer to other resource within the same server. 2.client or browser is not involved. 3.When forward is called on requestdispatcher object we pass request and response objects so our old request object is passed on for further processing. 4.ON browsers url you cant see that address.…

Read More Read More

Producer Consumer Problem in java

Oveririding rules

Rules for overriding The access level can’t be more restrictive than the overridden method’s.

  Compiles  fine

  Not Allowed

  Not Allowed

  Output: :2 The access level CAN be less restrictive than that of the overridden method. private, static and final methods can’t be overridden Return type of method is never part of method…

Read More Read More