Negative Binary Numbers

Arjun Thakur
Updated on 30-Jul-2019 22:30:24

17K+ Views

Negative numbers can be distinguishable with the help of extra bit or flag called sign bit or sign flag in Binary number representation system for signed numbers. It is not possible to add minus or plus symbol in front of a binary number because a binary number can have only two symbol either 0 or 1 for each position or bit. That’s why we use this extra bit called sign bit or sign flag. The value of sign bit is 1 for negative binary numbers and 0 for positive numbers.When an integer binary number is positive, the sign is represented ... Read More

Why NOT NULL Shouldn’t Be Added to Primary Key Field in MySQL

Chandu yadav
Updated on 30-Jul-2019 22:30:24

857 Views

You do not need to add NOT NULL to primary key field because it gets NOT NULL automatically. Primary key is combination of both NOT NULL and Unique Key.Here is the demo of primary key field. Let us first create a table. The query to create a table is as follows:mysql> create table NotNullAddDemo    -> (    -> Id int AUTO_INCREMENT,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.81 sec)In the above table, you do not need to add NOT NULL to primary key field because MySQL internally converts it into NOT NULL. To ... Read More

Get Last 5 Characters of a String with MySQL Query

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:24

20K+ Views

To get the first n characters of string with MySQL, use LEFT(). To get the last n char of string, the RIGHT() method is used in MySQL.The syntax for RIGHT() method is as follows −SELECT RIGHT(yourColumnName, valueOfN) as anyVariableName from yourTableName;To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table gettingLast5Characters    −> (    −> BookName varchar(100)    −> ); Query OK, 0 rows affected (0.73 sec)Now you can insert records in the table using insert command. The query is as follows −mysql> insert into gettingLast5Characters values('Introduction ... Read More

Order of Events of Republic Day Celebration at Red Fort

Ridhi Arora
Updated on 30-Jul-2019 22:30:24

864 Views

Republic day in India is celebrated on 26th of January every year and holds a seminal value. The day is celebrated in grandeur in the capital city's India Gate. Various events take place in the capital city and elsewhere to celebrate the framing of the Indian Constitution.Order of Events On Republic DayPrime Minister lays a floral wreath at Amar Jawan Jyoti. It is an Indian memorial constructed post the Indo-Pakistani War of 1971 to commemorate the martyred soldiers of the Indian Armed Forces who died during the war.President along with his bodyguards proceeds to the parade ground in Red Fort. ... Read More

Use headset() Method of Java NavigableSet Class

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

127 Views

The headset() method returns elements up to a limit defined as a parameter.First, create a NavigableSet and add elements −NavigableSet set = new TreeSet(); set.add(10); set.add(25); set.add(40); set.add(55); set.add(70); set.add(85); set.add(100);Now, use the headset() method −set.headSet(55));The following is an example −Example Live Demoimport java.util.NavigableSet; import java.util.TreeSet; public class Demo {    public static void main(String[] args) {       NavigableSet set = new TreeSet();       set.add(10);       set.add(25);       set.add(40);       set.add(55);       set.add(70);       set.add(85);       set.add(100);       System.out.println("Returned Value = " + ... Read More

Removing Single Elements in a Vector in Java

Rishi Raj
Updated on 30-Jul-2019 22:30:24

171 Views

A single element in the Vector can be removed using the java.util.Vector.remove() method. This method removes the element at the specified index in the Vector. It returns the element that was removed. Also after the element is removed from the specified index, the rest of the Vector elements are shifted to the left.A program that demonstrates this is given as follows:Example Live Demoimport java.util.Vector; public class Demo { public static void main(String args[]) { Vector vec = new Vector(5); vec.add(4); ... Read More

Raise X to the Power N Using Recursion in Java

Vikyath Ram
Updated on 30-Jul-2019 22:30:24

803 Views

The power of a number can be calculated using recursion. Here the number is x and it is raised to power n.A program that demonstrates this is given as follows:Example Live Demopublic class Demo {    static double pow(double x, int n) {       if (n != 0)          return (x * pow(x, n - 1));       else          return 1;    }    public static void main(String[] args) {       System.out.println("7 to the power 3 is " + pow(7, 3));       System.out.println("4 to the power 1 ... Read More

Copy All Elements of Java LinkedHashSet to an Object Array

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

225 Views

First, create a LinkedHashSet and add elements −LinkedHashSet l = new LinkedHashSet(); l.add(new String("1")); l.add(new String("2")); l.add(new String("3")); l.add(new String("4")); l.add(new String("5")); l.add(new String("6")); l.add(new String("7"));Now, copy it to an object array like this −// copying Object[] arr = l.toArray();The following is an example to copy all elements of a LinkedHashSet to an object array −Example Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { LinkedHashSet l = new LinkedHashSet(); l.add(new String("1")); l.add(new String("2")); ... Read More

MySQL Syntax: Not Evaluating with Not Equal Operator in Presence of Null

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

169 Views

Use the IS NOT NULL operator to compare with NULL values. The syntax is as follows −SELECT *FROM yourTableName where yourColumnName1 is not null or yourColumnName2 anyIntegerValue;To check the not equal to in presence of null, let us create a table. The query to create a table is as follows −mysql> create table IsNullDemo    −> (    −> ProductId int,    −> ProductName varchar(100),      −> ProductBackOrder int    −> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table with null value to avoid the presence of null. The query to insert records ... Read More

Opt for EMI Option Using Debit Card on E-commerce Websites

Vihan Rodrigues
Updated on 30-Jul-2019 22:30:24

95 Views

The online market is worth millions at the moment and there is a complete generation who loves shopping online, especially on EMI. I also purchased a Smart Television on last Diwali and that too on EMIs and still paying. However, I have the satisfaction of giving this as a surprise gift to my ‘die-hard web series’ fan wife who wanted to enjoy the streaming on a larger screen.However, many folks among us get deprived of picking the most needful air-conditioner at the blazing summer or the latest 8th generation laptop for higher studies just because they carry mere a debit ... Read More

Advertisements