Posts

Showing posts from September, 2015

calling a constructor..!!

                              Calling constructor First of all we all know that for what constructor is used for to initialize the members of class right..!! Same as we initialize normally or by method calling and in it we initialize but when constructor is called one answer we know generally when we define object that is when we instantiate the object at that time the constructor is called  what is the other method by can we call the constructor its by inheriting that class with other class and calling that classes constructor automatically the base class constructor will be called when we call the derived one. for example lets take a class Abc now we want to call the constructor of class Abc like Abc o1= new Abc( ) So constructor of Abc will be called automatically .  Now question arises that if we didnt define the constructor than will it call any one ,,? yess its a convention type thing that if we didn't define any constructor in class compiler def

open file...!!! what happens when you just give this command..!!

Before staring this article i would like to clear about what is RAM ....? So RAM is the memory with which we usually work in computer that is whatever is visible in our computer screen say if we opened a word document than that is visible to us and can change the data in it by modifiying the previous data or by writing the new document . The meaning of above sentence is simple that whatever we see in monitor or display device is RAM . SO NOW moving on  suppose you wrote something  in word now suddenly if light goes off then ..??? surely our data that we wrote will not be present and when  light comes , we switch on the computer we see that the data is destroyed..!!  so  this is the first charecteristic of RAM that is RAM is volatile (to vapuour up) now second thing happens is by mistake we closed our document then also same thing happens the data gets perished away....!! Now we want that our data might be safe and must be present whenever we want then...?? yess the r

lets make thread concept little easy............!!!!

Thread  The main reason for writing this post as I learnt a concept which is quite deeper for threads..!! First of all what is thread...? we will define thread first but for thread the main thing is operating system yes...!! operating system is the first thing we require for multithreading or threading . But which type of operating system we need that is the point the born of multithreading started. We need an operating system that would provide us a GUI platfoem not CUI platform well you all must be famalier with What is GUI and CUI .  As we have seen in DOS and in unix we can say that if we create a file by copy cone command till that if we want to execute any other command we have to back by pressing ctrl+z so the sole meaning here is to say that we cant do concurrent executions in Cmd . so clear the first point was that we need an operating system that would provide a GUI platform.  Now comming back to our question what is thread for that i would like

Usage of final keyword in java

Final Keyword In Java 1) Java final variable If you make any variable as final, you cannot change the value of final variable(It will be constant). final int  ACK //(generally it is the convention to give capital letters to the final variable we declare) It dosent occupy space in memory for multiple executions. Its good that it saves memory  2) Java final method If you make any method as final, you cannot override it. class  bird{      final   void  run(){System.out.println( "running" );}   }         class  animal  extends  bird{       void  run(){System.out.println( "animals eat birds" );}             public   static   void  main(String args[]){      animal lion=  new  animal();      animal.run();      }   }   if u will test it will have compile error 3) Java final class If you make any class as final, you cannot extend it. final   class  Bike{}      class  car  extends  Bike{      void  run(){System.out.printl

Applet(java) inner and deep conceptual meaning

                                                  Applet  Before staring about the discussion about applet first i would like to give the introduction about the applications .  First of all at at primary level we have two types of application  1)Desktop based application 2)web based application 1)Desktop based application:- defining in simple terms desktop applications are the applications                                                          whose output is seen on the desktop. 2)web based application:- web based application are those application whose output is seen on the                                                  web browser. Now as we all now that applet is somewhat related to website than why i didn't distinguished as Desktop application and applet.The reason is that a web page is the collection of different components or we can say that a web page is made up of different different tools , As far as we know to keep anything for example w

Introduction to appletviewer

                                          appletviewer As discussed in the previous post that what is appletviewer lets revise back again an appletviewer is a tool to view how our applet will look like by setting the size again and again we can check instantly that how it will appear. Why the use of appletviewer..? Every time the rule is to make an applet first extend the applet class that is inheritance and compile it a class file is produced with the byte code and and now the second step is open the notepad and write applet tag as stated in the previous post and save as .htm extension.  In the applet tag we have to provide a class file name . Last step is go in file menu and select our html file and open in browser the output is seen. The meaning is that whenever changes are to be made all this steps are to be performed again so becomes a tedious job to perform all this and as a plus point to the java users java provided appletviewer it is a code nothing else . H

Important questions can be asked in competitive exams...!!

                                 Important questions Q: What if the main method is declared as private? A: The program compiles properly but at runtime it will give "Main method not public." message. Q: What if the static modifier is removed from the signature of the main method? A: Program compiles. But at runtime throws an error "NoSuchMethodError". Q: What if I write static public void instead of public static void? A: Program compiles and runs properly. Q: What if I do not provide the String array as the argument to the method? A: Program compiles but throws a runtime error "NoSuchMethodError". Q: How can one prove that the array is not null but empty using one line of code? A: Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have th

Description about wait() notify() notifyAll() stop() suspend() and resume(),interprocess comminucation in java to avoid polling..

The use of the implicit monitors in Java objects is powerful, but you can achieve a more subtle level of control through inter-process communication. As you will see, this is especially easy in Java. Multithreading replaces event loop programming by dividing your tasks into discrete and logical units. Threads also provide a secondary benefit: they do away with polling. Polling is usually implemented by a loop that is used to check some condition repeatedly. Once the condition is true, appropriate action is taken. This wastes CPU time. For example, consider the classic queuing problem, where one thread is producing some data and another is consuming it. To make the problem more interesting, suppose that the producer has to wait until the consumer is finished before it generates more data. In a polling system, the consumer would waste many CPU cycles while it waited for the producer to produce. Once the producer was finished, it would start polling, wasting more CPU cycles waiting