What is Runnable interface in Java?

Swarali Sree
Published on 31-Dec-2017 15:24:39
If your class is intended to be executed as a thread, then you can achieve this by implementing a Runnable interface. This belongs to the java.lang package.

What is Callable interface in Java?

Sharon Christine
Published on 31-Dec-2017 15:26:50
The Callable interface is found in the package java.util.concurrent. The Callable object can return the computed result done by a thread in contrast to a runnable interface which can only run the thread. The Callable object returns a Future object which provides methods to monitor the progress of a task ... Read More

What is object cloning in Java?

Swarali Sree
Published on 31-Dec-2017 15:41:49
Object cloning is creating a copy of an object. The clone() method of the Object class of the java.lang package creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. Example Live Demo import java.util.GregorianCalendar; ... Read More

How to match at the end of string in python using Regular Expression?

Rajendra Dharmkar
Published on 02-Jan-2018 10:57:17
The following code matches the word 'stadium' at the end of the string ' cheer leaders at the football stadium'$-matches the end of the stringimport re s = 'cheer leaders at the football stadium' result = re.search(r'\w+$', s) print result.group()This gives the outputstadium

What is constructor chaining in Java?

Sai Subramanyam
Published on 31-Dec-2017 15:54:30
Constructors are similar to methods but, They do not have any return type. The name of the constructor is same as the name of the class. Every class has a constructor. If we do not explicitly write a constructor for a class, the Java compiler builds a default constructor ... Read More

Can you use both this() and super() in a constructor in Java?

Samual Sam
Published on 31-Dec-2017 15:55:39
No, you cannot have both this() and super() in a single constructor.

What is the difference between shallow copy and deep copy in Java?

Swarali Sree
Published on 31-Dec-2017 15:57:04
When we copy an object, a shallow copy is where only the outer object is copied. For example, if we have an object named sample and it contains another object named subSample then if you copy this only the contents of the sample are copied.When we copy an object deep ... Read More

How to match at the beginning of string in python using Regular Expression?

Rajendra Dharmkar
Published on 02-Jan-2018 10:38:02
The following code matches the word 'cheer' at the beginning of the string ' cheer leaders at the football stadium'^-matches the beginning of the stringimport re s = 'cheer leaders at the football stadium' result = re.search(r'^\w+', s) print result.group()This gives the outputcheer

How can we use complex numbers in Python?

Pythonista
Published on 02-Jan-2018 00:07:42
A complex number is a pair of real numbers a and b, most often written as a+bi, or a+ib, where i is called the imaginary unit and acts as a label for the second term. Mathematically,  i2 = -1. Sometimes, j is used instead of i.Here’s how a complex number ... Read More

How do we create python string from list?

Pythonista
Published on 02-Jan-2018 00:06:02
Python has an in-built join() function that returns a string by joining elements in a sequence object by inserting separator between elements. If we need a string without any separator, we initialize it with null string>>> lst=['h', 'e', 'l', 'l', 'o'] >>> str='' >>> str.join(lst) 'hello' Read More
Advertisements