JAVA
public class Main {
public static void main(String[] args) {
String x = "10";
int y = 20;
String z = x + y;
System.out.println(z);
}
}
Explanation :
This program demonstrates string concatenation and type coercion in Java. When a String is added to a primitive data type like an int using the + operator, Java automatically converts the integer into a string and concatenates them together rather than performing mathematical addition.
Step-by-step breakdown:
-
String x = "10";: Declares a string variable namedxholding the text"10". -
int y = 20;: Declares an integer variable namedyholding the numeric value20. -
String z = x + y;: Combinesxandy. Becausexis aString, the integeryis converted to the string"20"and joined with"10", resulting in the string"1020". -
System.out.println(z);: Prints the final value ofzto the console.
The output of the program will be:
1020
SQL
Text Fields vs. Numeric Fields
SQL requires single quotes around text values (most database systems will also allow double quotes).
However, numeric fields should not be enclosed in quotes:
Example
SELECT * FROM Customers
WHERE CustomerID = 1;
References :
https://www.w3schools.com/sql/sql_where.asp
https://www.w3schools.com/java/java_examples.asp
Top comments (0)