Java was built by sheer accident, a team of developers were busy building a set top box, and began cleaning C++. When they were winding up these changes, they ended up discovering Java and its runtime environment.Many of you might be aware of this, but for those who aren’t, Java wasn’t the original name that was decided for this language. It was ‘Oak’. Sun Marketing system changed the name later when they realized that a company named ‘Oak’ existed.It is a widely used language all over the world, and is considered to be a favourite amongst the developer group, and ... Read More
There are many interesting facts with respect to increment and decrement operators in Java. We will discuss a few of them with examples −The increment and decrement operators can’t be used with the ‘final’ variables. This is due to the fact that variables associated with ‘final’ keyword can’t be changed −Example Live Demopublic class Demo{ public static void main(String[] args){ final int my_val = 34; int my_val_2 = ++my_val; System.out.println("The value is :"); System.out.println(my_val_2); } }Output/Demo.java:6: error: cannot assign a value to final variable my_val int my_val_2 ... Read More
There are many facts with respect to array assignment, and we will discuss a few of them with working examples here −While creating array object type, the element that would be present inside the array can be declared as type objects or as child class’s object.Example Live Demopublic class Demo{ public static void main(String[] args){ Number[] my_val = new Number[3]; my_val[0] = new Integer(91); my_val[1] = new Double(65.963); my_val[2] = new Double(45.7965); System.out.println(my_val[0]); System.out.println(my_val[1]); System.out.println(my_val[2]); } }Output91 65.963 ... Read More
Java compiler doesn’t allow abandoning an uninitialized local variable. When a local variable is initialized inside a conditional block, there are 3 possibilities that could potentially occur −Code compiles successfully if values are provided in the conditional block and the given condition is true.Code gives a compilation error if variables are provided (instead of values) in the conditional block and the condition is true.Code gives compilation error if the condition that needs to be checked is false.If the local variable is initialized to a default value outside of the conditional block in the code, it won’t give any error and ... Read More
Use the justify-content property with value space-between to add space between the lines.ExampleYou can try to run the following code to implement the space-between value −Live Demo .mycontainer { display: flex; background-color: red; justify-content: space-between; } .mycontainer > div { background-color: white; text-align: center; line-height: 60px; font-size: 30px; width: 100px; margin: 5px; } Quiz Q1 Q2 Q3 Q4
Use the align-content property with value flex-end to set the flex lines in the end.ExampleYou can try to run the following code to implement the flex-end valueLive Demo .mycontainer { display: flex; height: 200px; background-color: blue; align-content: flex-end; flex-wrap: wrap; } .mycontainer > div { background-color: orange; text-align: center; line-height: 60px; font-size: 30px; width: 100px; margin: 5px; } Queue Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8
Increase the size of a flex item, using the flex-grow property. Use it with one or more than flex items.ExampleYou can try to run the following code to implement the flex-grow property. Here Q3 flex-item is larger than other items −Live Demo .mycontainer { display: flex; background-color: orange; align-content: space-between; } .mycontainer > div { background-color: white; text-align: center; line-height: 40px; font-size: 25px; width: 100px; margin: 5px; } Quiz Q1 Q2 Q3 Q4 Q5
Following is the code to implement Checksum using Java −Example Live Demoimport java.util.*; public class Demo{ public static void main(String args[]){ Scanner my_scan = new Scanner(System.in); System.out.println("Enter the input string "); String my_in = my_scan.next(); int my_checksum = generate_checksum(my_in); System.out.println("The checksum that has been generated is " + Integer.toHexString(my_checksum)); System.out.println("Enter the data that needs to be sent to the receiver "); my_in = my_scan.next(); System.out.println("Enter the checksum that needs to be sent to the receiver "); ... Read More
Set the length of a flex item with the flex-basis CSS property.ExampleYou can try to run the following code to implement the flex-basis property −Live Demo .mycontainer { display: flex; background-color: orange; } .mycontainer > div { background-color: white; text-align: center; line-height: 40px; font-size: 25px; width: 100px; margin: 5px; } Quiz Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9
Use the flex-direction property with column-reverse value to set the flex-items vertically, from top to bottomExampleYou can try to run the following code to implement the column-reverse value −Live Demo .mycontainer { display: flex; flex-direction: column-reverse; background-color: orange; } .mycontainer > div { background-color: white; text-align: center; line-height: 40px; font-size: 25px; width: 100px; margin: 5px; } Quiz Q1 Q2 Q3 Q4 Q5 Q6