The HTML DOM Base object is associated with the HTML element. The element is used to specify the base url for all other URLs in the HTML document. There can at most one element in an HTML document. The Base object is used to set or get the href attribute of the element.PropertiesFollowing are the properties of Base object −PropertyDescriptionhrefSets or returns the value of the href attribute in a base elementtargetSets or returns the value of the target attribute in a base elementSyntaxFollowing is the syntax for −Creating the base element −document.createElement ("base")Accessing the base ... Read More
The HTML DOM Base href property is associated with the HTML tag. The tag is used to specify the base URL for all relative URLs in the current HTML document. There can be a maximum of one tag in a HTML document. The Base href Property returns the value of href attribute in the base element.SyntaxFollowing is the syntax for −Setting the href property −baseObject.href = URLHere, URL is the base URL.Returning the href property −baseObject.hrefExampleLet us see an example for Base href Property − IMAGES Click the below button to change ... Read More
The HTML DOM Area Object is associated with the image map in HTML. Area basically represents the clickable area inside the image map.The image object helps us in creating and accessing the element within the object. We can change clickable region inside the map or change the shape etc. of the image map based on the user input. It can also be used to manipulate the link inside the area elementPropertiesFollowing are the properties for Area Object −ValueDescriptionaltTo set or return alt attribute value.coordsTo set or return the cords attributes of an area.hashTo set or return the anchor part ... Read More
The HTML DOM Body object is associated with the HTML element. The attributes and their values set inside the body tag stay throughout the HTML document unless they are overridden by any of its child node.The body object can be used to access and manipulate these properties and their values.PropertiesFollowing are the properties for HTML DOM Body object −Note − The properties below are not supported in HTML5 .Use CSS instead −PropertyDesciptionaLinkTo set or return the active link color in a document.backgroundTo set or return the background image for the documentbgColorTo set or return the background color of the ... Read More
The HTML DOM Bdo dir property is associated with the HTML element. Here, bdo stands for Bi-Directional Override. The tag is used to override the current text direction which is by default left to right. The bdo dir property sets or returns the dir attribute value of a element. The dir property is compulsory for the element. It specifies the direction of the text flow.SyntaxFollowing is the syntax for −Setting the dir property −bdoObject.dir = "ltr|rtl"Here, ltr is left-to-right text direction, whereas rtl is right-to-left text direction.Returning the dir property −bdoObject.dirExampleLet us see an example for HTML ... Read More
The HTML DOM Button autofocus property is associated with autofocus property of the element. The button autofocus property is used to specify whether a button on the HTML document should get the focus or not when the page loads.SyntaxFollowing is the syntax for −Setting the button autofocus property −buttonObject.autofocus = true|falseHere, the true|false specifies if the given input button should get the focus on not when the page loads.True − Input button gets focusFalse − Input button doesn’t get focus.ExampleLet us see an example for the HTML DOM button autofocus property − BUTTON Click the below button to know ... Read More
The HTML DOM bold object is associated with the html (bold) tag. The tag is used to make the text inside the tag bold .Using the bold object we can access the HTML tag.SyntaxFollowing is the syntax for −Creating a bold object −var x = document.createElement("B");ExampleLet us see an example for the HTML DOM Bold object − Click the below button to create a element with some text CREATE function createBold() { var x = document.createElement("B"); var t = document.createTextNode("SAMPLE BOLD TEXT"); ... Read More
Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) namely, boolean, byte, char, short, int, long, float, double and, reference datatypes (arrays and objects).Casting in JavaConverting one primitive data type into another is known as type casting.Exampleimport java.util.Scanner; public class TypeCastingExample { public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.println("Enter an integer value: "); int i = sc.nextInt(); long num = i; System.out.println("Value of the given integer: "+num); } }OutputEnter an integer ... Read More
No, for that matter to throw any exception explicitly you need to create an object of that exception and throw it using the throw keyword.Without creating an object you cannot throw an exception explicitly, you might create a scenario that causes the respective exception.ExampleFollowing Java program throws a NullPointerExceptionpublic class ExceptionExample { public static void main(String[] args) { System.out.println("Hello"); NullPointerException nullPointer = new NullPointerException(); throw nullPointer; } }OutputHello Exception in thread "main" java.lang.NullPointerException at MyPackage.ExceptionExample.main(ExceptionExample.java:6)
While reading values from the user in the constructor or any method you can validate those values using if condition.ExampleIn the following Java example we are defining two custom exception classes verifying name and age.import java.util.Scanner; class NotProperAgeException extends Throwable{ NotProperAgeException(String msg){ super(msg); } } class NotProperNameException extends Throwable{ NotProperNameException(String msg){ super(msg); } } public class CustomException{ private String name; private int age; public static boolean containsAlphabet(String name) { for (int i = 0; i < name.length(); i++) { char ch = name.charAt(i); if (!(ch >= 'a' && ch
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP