Difference Between throw and throws in Java

Nitin Sharma
Updated on 18-Sep-2019 14:29:22

11K+ Views

Both throw and throws are the concepts of exception handing in which throw is used to explicitly throw an exception from a method or any block of code while throws are used in the signature of the method to indicate that this method might throw one of the listed type exceptions.The following are the important differences between throw and throws.Sr. No.Keythrowthrows1DefinitionThrow is a keyword which is used to throw an exception explicitly in the program inside a function or inside a block of code.Throws is a keyword used in the method signature used to declare an exception which might get ... Read More

Difference Between Thread.start() and Thread.run() in Java

Nitin Sharma
Updated on 18-Sep-2019 14:28:24

6K+ Views

As we know that start() and run() are the two important methods of multithreading and one is used to create a new thread while other is used to start executing that thread.Following are the important differences between Thread.start() and Thread.run().Sr. No.Keystart()run()1Implementationstart method of thread class is implemented as when it is called a new Thread is created and code inside run() method is executed in that new Thread.While if run method is executed directly than no new Thread is created and code inside run() will execute on current Thread and no multi-threading will take place.2Definitionstart method is defined in thread ... Read More

Difference Between String and Character Array in Java

Nitin Sharma
Updated on 18-Sep-2019 14:27:27

6K+ Views

On technical groud, we can say that both a character array and string contain the sequence of characters and used as a collection of characters. But there are significant differences between both which we would discuss below.The following are the important differences between String and Character array.Sr. No.KeyStringCharacter array1ImplementationString is implemented to store sequence of characters and to be represented as a single data type and single entity.Character Array on the other hand is a sequential collection of data type char where each element is a separate entity.2Internal implementationString internal implementation makes it immutable in nature.Character array is mutable in ... Read More

Difference Between Singly Linked List and Doubly Linked List in Java

Nitin Sharma
Updated on 18-Sep-2019 14:25:53

4K+ Views

Both Singly linked list and Doubly linked list are the implementation of Linked list in which every element of singly-linked list contains some data and a link to the next element, which allows to keep the structure. On the other hand, every node in a doubly-linked list also contains a link to the previous node.The following are the important differences between a Singly linked list and Doubly linked list.Sr. No.KeySingly linked listDoubly linked list1ComplexityIn singly linked list the complexity of insertion and deletion at a known position is O(n)In case od doubly linked list the complexity of insertion and deletion ... Read More

Difference Between print and println in Java

Nitin Sharma
Updated on 18-Sep-2019 14:23:00

6K+ Views

As we know in Java these both methods are primarily used to display text from code to console. Both these methods are of PrintStream class and are called on static member 'out' of 'System' class which is a final type class.The following are the important differences between print() and println().Sr. No.Keyprint()println()1Implementationprint method is implemented as it prints the text on the console and the cursor remains at the end of the text at the console.On the other hand, println method is implemented as prints the text on the console and the cursor remains at the start of the next line ... Read More

Difference Between ODBC and JDBC

Nitin Sharma
Updated on 18-Sep-2019 14:22:22

15K+ Views

Both ODBC and JDBC are the programming interface that is required by the applications at the client side to access the database at server side. Basically both are known as drivers to get connected with a database and are provided by the vendors of RDBMS.The following are the important differences between ODBC and JDBC.Sr. No.KeyODBCJDBC1Stands ForODBC stands for Open Database Connectivity which literally means that it is compatible with all types of languages such as C, C++, Java, etc.JDBC Stands for Java database connectivity i.e only compatible with java language.2IntroductionODBC was introduced by Microsoft prior to JDBC in 1992.JDBC was ... Read More

Differences Between wait() and join() Methods in Java

Nitin Sharma
Updated on 18-Sep-2019 14:16:47

3K+ Views

In multithreading when we deal with threads there comes the requirement of pause and start a thread for this Threading provides two methods wait and join which are used for the same.The following are the important differences between wait() and join().Sr. No.Keywait()join()1Declarationwait() method is defined in Object class and hence the wait() method is declared in java.lang package.join() method, on the other hand, is also defined in java.lang package but in Thread class.2Usagewait() method is primarily used for the inter-thread communication.On the other hand join() is used for adding sequencing between multiple threads, one thread starts execution after first thread ... Read More

Class Keyword in JavaScript

Ayush Gupta
Updated on 18-Sep-2019 13:14:06

260 Views

JavaScript classes, introduced in ES6, are syntactical sugar over JavaScript prototype-based inheritance. Classes are in fact "special functions". You can define classes in JavaScript using the class keyword using the following syntax −class Person {    // Constructor for this class    constructor(name) {       this.name = name;    }    // an instance method on this class    displayName() {       console.log(this.name)    } }This is essentially equivalent to the following declaration −let Person = function(name) {    this.name = name; } Person.prototype.displayName = function() {    console.log(this.name) }This class can also be written as ... Read More

JavaScript RegExp with Metacharacter

Ayush Gupta
Updated on 18-Sep-2019 12:32:45

262 Views

The \W metacharacter is used to find a non-word character.A word character is a character from a-z, A-Z, 0-9, including the _ (underscore) character.Example// Containing any non word character: console.log(/\W/.test(" ")) console.log(/\W/.test(".!@#")) // Not containing non word characters: console.log(/\W/.test("a")) console.log(/\W/.test("B")) console.log(/\W/.test("9")) console.log(/\W/.test("_"))Outputtrue true false false false false

JavaScript RegExp s Metacharacter

Ayush Gupta
Updated on 18-Sep-2019 12:26:19

150 Views

The \s metacharacter is used to find a whitespace character.A whitespace character can be −A space characterA tab characterA carriage return characterA new line characterA vertical tab characterA form feed characterExample// Not containing any white spaces: console.log(/\s/.test("1")) console.log(/\s/.test("test")) // Containing whitespace characters: console.log(/\s/.test(" ")) console.log(/\s/.test("a\tb")) console.log(/\s/.test("mn"))Outputfalse false true true true

Advertisements