Amit Sharma has Published 43 Articles

What is a blank uninitialized final variable in java?

Amit Sharma

Amit Sharma

Updated on 02-Sep-2022 13:31:00

A final variable can be explicitly initialized only once. A reference variable declared final can never be reassigned to refer to a different object. However, the data within the object can be changed. So, the state of the object can be changed but not the reference. With variables, the final ... Read More

How can I pop-up a print dialog box using JavaScript?

Amit Sharma

Amit Sharma

Updated on 17-Jun-2020 06:09:24

To pop-up a print dialog box using JavaScript, use the print() method. With the dialog box, you can easily set the printing options like which printer to select for printing.This is the dialog box −ExampleYou can try to run the following code to learn how to print a page −Live ... Read More

What are the default values of instance variables whether primitive or reference type in Java?

Amit Sharma

Amit Sharma

Updated on 16-Jun-2020 11:40:00

When we haven’t initialized the instance variables compiler initializes them with default values.For boolean type, the default value is false, for float and double types default values are 0.0 and for remaining primitive types default value is 0.ExampleLive Demopublic class Sample {    int varInt;    float varFloat;    boolean ... Read More

How to refresh a page in Firefox?

Amit Sharma

Amit Sharma

Updated on 16-Jun-2020 08:03:10

To refresh a page in a web browser like Firefox means reloading the page. It’s quite easy to refresh a page. Follow the below given steps −Open web pageOpen the web page, which you want to refresh.Find Refresh buttonThe refresh button is located on the top right corner of the ... Read More

How to create a valid HTML document with no and element?

Amit Sharma

Amit Sharma

Updated on 15-Jun-2020 11:45:48

With HTML, the essentials are doctype declaration, and . But, you will be amazed to know that a valid HTML document can work without the and element. The doctype declaration will come always since it tells and instructs the browser about what the page is about.Let’s see ... Read More

How to design a responsive website?

Amit Sharma

Amit Sharma

Updated on 15-Jun-2020 08:37:57

A responsive website is a website that looks good and amazing on all devices i.e. desktops, tablets, and cell phones. A website should have a responsive design to make it responsive. It’s all about playing around with HTML and CSS for changing the size, hiding, or enlarging the screen.Let’s see ... Read More

What is increment (++) operator in JavaScript?

Amit Sharma

Amit Sharma

Updated on 15-Jun-2020 05:39:26

The increment operator increases an integer value by one. Here’s an example where the value of a is incremented twice using the increment operator twiceExampleLive Demo                    var a = 33;          a = ++a;          document.write("++a = ");          result = ++a;          document.write(result);          

How to generate random whole numbers in JavaScript in a specific range?

Amit Sharma

Amit Sharma

Updated on 15-Jun-2020 05:25:14

To generate a random number, use the JavaScript Math.random() method. Here set the minimum and maximum value and generate a random number between them as in the following code −ExampleLive Demo                    var max = 6          var min = 2          var random = Math.floor(Math.random() * (max - min + 1)) + min;          document.write(random)          

What are Reserved Words in JavaScript?

Amit Sharma

Amit Sharma

Updated on 13-Jun-2020 11:40:24

Reserved words cannot be used as JavaScript variables, functions, methods, loop labels, or any object names.Here are the reserved words in JavaScript −abstractElseinstanceofswitchbooleanEnumintsynchronizedbreakExportinterfacethisbyteExtendslongthrowcaseFalsenativethrowscatchFinalnewtransientcharFinallynulltrueclassFloatpackagetryconstForprivatetypeofcontinueFunctionprotectedvardebuggerGotopublicvoiddefaultIfreturnvolatiledeleteimplementsshortwhileDoImportstaticwithdoubleInsuper

How to check if a variable exists in JavaScript?

Amit Sharma

Amit Sharma

Updated on 13-Jun-2020 08:28:18

To check if a variable exists in JavaScript, you need to check it against null as in the following code. Here, we’re checking the existence of variable myVar −                    var myVar = 20;          if(myVar !== undefined && myVar !== null) {             document.write("Variable exists");          }          

Advertisements