by Dinesh Thakur

Strings often used in programming. Most of the programs use strings such as names, addresses, messages and many more. A string is a sequence of Unicode characters. Unlike most of the programming languages such as C/C++ where strings treated as an array of characters, Java treats a string as an object. Java provides the following classes for storing and processing strings.

 
by Dinesh Thakur

Elements that can be added to the Vector must be of type java .lang. Object. In other words, vectors cannot handle primitive data typeslike int, float, char and double as they are not objects. So in order to work with primitive type variables as if they were objects, Java provides class for each of the primitive types. These classes are known as wrapper classes.



 
by Dinesh Thakur

Multi-dimensional arrays that contain more than one index and can store information in multiple dimensions.  The most common one is a two-dimensional array, also called a matrix or table. In the two-dimensional array, each element associated with two indexes.  We can visualize the two-dimensional array as a spreadsheet, rectangular in shaper and containing elements that divided into columns and rows. However, Java does not indeed support multidimensional arrays. However, one can achieve the same functionality by declaring an array of arrays.



 
by Dinesh Thakur

Arrays Definition: Perhaps one of the most important of all concepts that you need to learn to be effective is the array. Until now, we have looked at variables that hold just one value – the ints hold one number and the strings hold one text string. Arrays are used when we want to hold two or more values, perhaps a list. Arrays can be thought as columns in a spreadsheet – a spreadsheet can have one, or it can have many columns.  

 
by Dinesh Thakur

A nested class as the name suggests is a class that is defined inside another class. It is merely a convenient way of grouping two or more classes together into a single unit or module. A class that contains a nested class is known as the enclosing or outer class of the nested class.

 
by Dinesh Thakur

Method Overloading: When multiple methods in the same class with same name, having different functions or types of parameters, it is known as Method Overloading. When an overloaded method is invoked, it is the responsibility of the compiler to select the appropriate overloaded method based on the number of argument(s) passed and if the numbers of argument(s) are same then depending upon the type of argument(s) passed to the method. Thus, the key to method overloading is a method's parameter list. A method's return type is not enough to distinguish between two overloaded methods. If the compiler detects two methods declarations with the same name and parameter list but different return types then it will generate an error.

 
by Dinesh Thakur

Interfaces and abstract classes both implements polymorphic behaviour and seem to be similar but they are different in the following ways:
1. An interface is purely abstract i.e. methods in an interface only have declarations no implementations. On the other hand, abstract class methods may or may not have an implementation.

 
by Dinesh Thakur

A thread can undergo some states during its life cycle. It is because in a multithreaded environment when multiple threads are executing only one thread can use the CPU at a time, and all other threads should be in some other states either waiting for their turn for the CPU or waiting for some other condition to be satisfied.

A thread is always in one of five states: newborn, runnable, running, dead and blocked. Figure shows the life cycle of a thread.

 
by Dinesh Thakur

Every thread in Java has a priority that helps the thread scheduler to determine the order in which threads scheduled. The threads with higher priority will usually run before and more frequently than lower priority threads. By default, all the threads had the same priority, i.e., they regarded as being equally distinguished by the scheduler, when a thread created it inherits its priority from the thread that created it. However, you can explicitly set a thread's priority at any time after its creation by calling its setPriority() method. This method accepts an argument of type int that defines the new priority of the thread. Its syntax is.

 
by Dinesh Thakur

Java Thread: One of the dominant features of the Java language is that it provides built-in support for multithreading - the concurrent running of multiple threads within the same program. Creating a thread in Java is relatively easy. Unlike the old fashioned programming languages, where you have to invoke system-dependent procedures and functions to implement multithreading, in Java, it is no harder than creating an instance of other classes.

The programs that we have written so far had only one entry point (main() method) and one exit point. All the instructions in these programs executed serially one at a time beginning at the first statement in main () and continuing sequentially through the statements until the program ends. This single sequence of executable statements within a program is known as a thread. In other words, a thread is s flow of execution of a task in a program, so it is known as a thread of execution or a thread of control.

 

Page 3 of 8

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.