Rishi Raj has Published 155 Answers

How to set background color in HTML?

Rishi Raj

Rishi Raj

Updated on 22-Dec-2021 07:57:31

To set the background color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <body> tag, with the CSS property background-color. HTML5 do not support the <body> tag bgcolor attribute, so the CSS style is used ... Read More

Duplicating Objects using a Constructor in Java

Rishi Raj

Rishi Raj

Updated on 30-Jun-2020 08:44:29

A copy constructor can be used to duplicate an object in Java. The copy constructor takes a single parameter i.e. the object of the same class that is to be copied. However, the copy constructor can only be explicitly created by the programmer as there is no default copy constructor ... Read More

Pass long parameter to an overloaded method in Java

Rishi Raj

Rishi Raj

Updated on 30-Jun-2020 08:41:58

Method overloading in a class contains multiple methods with the same name but the parameter list of the methods should not be the same. One of these methods can have a long parameter in their parameter list.A program that demonstrates this is given as follows −Example Live Democlass PrintValues {   ... Read More

Role of Matcher.find(int) method in Java Regular Expressions

Rishi Raj

Rishi Raj

Updated on 30-Jun-2020 08:37:18

The Matcher.find(int) method finds the subsequence in an input sequence after the subsequence number that is specified as a parameter. This method is available in the Matcher class that is available in the java.util.regex package.The Matcher.find(int) method has one parameter i.e. the subsequence number after which the subsequence is obtained ... Read More

Why variables are declared final in Java

Rishi Raj

Rishi Raj

Updated on 30-Jun-2020 08:32:59

A variable cannot be modified after it is declared as final. In other words, a final variable is constant. So, a final variable must be initialized and an error occurs if there is any attempt to change the value.A program that demonstrates a final variable in Java is given as ... Read More

Get current thread in Java

Rishi Raj

Rishi Raj

Updated on 30-Jun-2020 08:30:48

A thread can be created by implementing the Runnable interface and overriding the run() method.The current thread is the currently executing thread object in Java. The method currentThread() of the Thread class can be used to obtain the current thread. This method requires no parameters.A program that demonstrates this is ... Read More

Enumerate through the Vector elements in Java

Rishi Raj

Rishi Raj

Updated on 30-Jun-2020 08:25:07

The Vector elements can be traversed using the Enumeration interface. The method hasMoreElements( ) returns true if there are more elements to be enumerated and false if there are no more elements to be enumerated. The method nextElement( ) returns the next object in the enumeration.A program that demonstrates this ... Read More

How a Vector can be cloned in Java

Rishi Raj

Rishi Raj

Updated on 30-Jun-2020 08:16:58

A Vector can be cloned using the java.util.Vector.clone() method. This method does not take any parameters but returns a clone of the specified Vector instance as an object.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Vector; public class Demo {    public static void main(String args[]) { ... Read More

Add elements at the middle of a Vector in Java

Rishi Raj

Rishi Raj

Updated on 30-Jun-2020 08:10:00

Elements can be added in the middle of a Vector by using the java.util.Vector.insertElementAt() method. This method has two parameters i.e. the element that is to be inserted in the Vector and the index at which it is to be inserted. If there is an element already present at the ... Read More

Python program using the map function to find a row with the maximum number of 1's

Rishi Raj

Rishi Raj

Updated on 23-Jun-2020 16:26:30

2D array is given and the elements of the arrays are 0 and 1. All rows are sorted. We have to find row with maximum number of 1's. Here we use map ().The map function is the simplest one among Python built-ins used for functional programming. These tools apply functions ... Read More

1 2 3 4 5 6 7 ... 16 Next
Advertisements