Skip to main content

Posts

Showing posts with the label JAVA BASICS NOTES

Acronyms to remember in computer science

 Acronyms to remember in computer science ALU → Arithmetic Logic Unit ASCII→ American Standard Code for Information Interchange BCD→ BinaryCodedDecimalCode BASIC—> Beginners All Purpose Symbolic CAD→ Computer Aided Design CD→ Compact Disc C_DOT→ Center for Development of Telematics CLASS→ Computer Literacy and study for School C_DAC→ Center for Development of Advanced Computing CD-ROM —> Compact Disk Read Only Memory CPU —> Central Process Unit CRT —> Cathod Ray Table DOS→ Disk Operating System DTP→ Desktop Publishing ENIAC→ Electronic Numerical Integrator and Calculator E MAIL —> Electronic Mail FAT —> File Allocation Table HD —> Hard Disk HTML→ Hypertext Markup Language HTTP→ Hypertext Transfer Protocol IBM→ International Business Machine ISDN→ Integrated Services Digital Network ISP —> Internet Service Protocol IC —> Integrated Circuit LCD —> Liquid Crystal Display LAN —> Local Area Network MICR —> Magnetic Ink Charactor Reader MIME —>Mult...

Thread synchronization in java

 Java thread synchronization and types  what is synchronization how it work short explanation? synchronization is a technique through which we can control multiple thread execution at a time. If you apply the synchronization concepts on the thread instruction, automatically whatever the thread is executing the instruction, that thread will be in a lock procedure so that no other thread will interrupt this thread.All remaining thread will wait for until the running thread is completed. synchronization can be achieved in three way  Synchronized keyword —> Applied for method  As a prefix to the method in which statements written to be executed as a thread. synchronized block —> Applied for inside the method This should be applied inside the method,If we want to restrict this synchronization for a few lines in a method. Syntax synchronization(this){ Statements } synchronized static block ---> Applied for method Syntax Synchronization static return type method na...

Thread class methods in java

 Java thread class methods and its function  Thread class contains different methods, using these methods we can manipulate the thread. Some methods are given below. Thread class methos and its funtion start()---->A thread execution started from the start() method,unless you implement the start() method thread will not be started. run()----> implicitly called by the start() method sleep(milliseconds)---->suspends the thread for given milliseconds of time,This should be written in the try catch block as the exception occurs.This is a static method,So this method can be called directly. join()---->waits the thread to complete its process,used in multi threading,it should be written in the try catch block as the exception occurs.This is a static method,So this method can be called directly. getId()---->Gives the ID of the thread getName()---->Gives thread names,always start from thread-0 setName(sting)---->Thread name will be replace with given string getPri...

Thread Life Cycle in Java

 Life Cycle of Thread in Java Programming In java, thread is a class. We know that class consists of a number of methods, variables, constructors etc. Here also the thread class consists of a number of methods. In order to access those methods first create an object for thread class. Thread life cycle has five states. From the creation up to the terminating the thread will move in five different states; these are called thread life cycles . Whenever a thread is created it is moved to a new state.In other words, the state where a thread is created and it is not running is called the newborn state . Whenever a thread is ready to execute the task it moves to runnable state, but is not executed currently.when the start() method is called on the new born thread, it will be in runnable state . After the runnable state, if the thread gets CPU access, it moves into the running state . If the CPU, completes without interrupting the process, it will move to a stop state. If any I/O inter...

Multithreading in java

Explanation of multithreading in java programming What is multithreading in java in simple words? Multithreading Multithreading is a powerful programming tool that makes it possible to achieve concurrent execution of multiple units of a program.In another word it is Concurrent execution of several parts of the same program at same time(This will improve CPU utilization). Advantages of multithreading in java Multi threading support for java includes thread creations,thread prioritizing,thread scheduling,resource locking (thread synchronization)and establishing inter thread communication. What is thread and how to create a thread in java? A thread can be defined as a process in execution within a program. A thread is a lightweight process and it is an individual part of a running program. Group of threads is called a program.All these threads will be working concurrently. There are two ways to create a thread. 1 By extending the thread class 2 By implementing the runnable interface

Explanation of 'try catch finally' block in java programming

 try-catch-finally block in java programming try block To handle a run time error and monitor the results,we simply enclose the code inside a try block.If an exception occurs within the try block,it is handled by the appropriate exception handler ( catch block) associated with the try block.A try block should have one (or more) catch blocks  or one finally block or both.Exception handlers are put in association with a try block by providing one or more catch block directly after the try block Syntax of try catch and finally block try { //java statements(risky code)      }      catch(Exception e)      {      //handled code      }     finally     {          //cleanup code          } catch block A catch block is specified by the keyword catch followed by a single argument within parentheses().A catch block is a group ...

Exception Handling in java programming

 Exception Handling and types of exception handling in java programming Exception handling in java programming Exception handling means avoiding abnormal termination of the program.Different types of error occur in our program,such as user errors,logic errors or system errors.When an exception occurs, it makes further execution of the program impossible.Java offers an excellent exception handling mechanism which is easy to understand and implement.Whenever an error occurs during the execution of a program,it throws an exception.If the exception is not handled properly, the program execution  is terminated. What is an exception handling mechanism in java? Exception handling is a mechanism that enables programs to detect and handle errors before they occur rather than allowing them to occur and suffering the consequences. Handling Exception In Java  Exception handling in java is accomplished by using  five keywords. try,catch,throw,throws and finally . Java exception ...

Java main method explanation

Explantion and Importance of main() method in java programming Explanation of main() method in java programming The entry point of executing a Java program is the main method. We know that Java programs work in oops concepts. Java programs are treated as objects and classes. If there is more than one class in a program,The program should be named using the class containing the main() method,because main() method is the entry point of Java program. java main method explanation Syntax of main method public static void main ( String args[] ){   } Importance of main function in java programming Here the public is an access modifier.There are different modifiers available in java If a function is declared public, the scope of the function is the entire program. Static keyword is the keyword where we can directly access the method without object.If the method is static , then such method can be accessed directly.Here void is a return type.Every method has a return type.When writ...

Difference Between Overloading and Overriding in Java programming

   overloading vs overriding in java What is polymorephism? Implementing same thing in different way is called polymorphism It divide into two category  1 compile time→ this can be  achieved by implementing method overloading  2 Run time—> this can be  achieved by  implementing method overriding Difference between overloading and overriding Overriding occurs when the method signature is the same in the superclass and the child class. Overloading occurs when two or more methods in the same class have the same name but different parameters