Ankitha Reddy

Ankitha Reddy

45 Articles Published

Articles by Ankitha Reddy

Page 3 of 5

Creating multiple Java objects by one type only

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 2K+ Views

You can create a List of object easily. Consider the following example, where I'll create an array of Employee objects and print their details in a for loop. import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; public class Tester implements Cloneable { private int data; public int getData() { return data; } public void setData(int data) { this.data = data; } public Tester(int data){ ...

Read More

Set the font variant with CSS

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 117 Views

To set the font variant, use the font-variant property. Set the font to small-caps and normal. You can try to run the following code to set the font-variant to small-caps with CSS − This text will be rendered as small caps

Read More

Execute a script when a Web Storage area is updated in HTML?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 179 Views

Use the onstorage attribute in HTML to execute on Web Storage area update. You can try to run the following code to implement onstorage attribute − Example HTML onstorage Welcome Demo text

Read More

How can we add a FOREIGN KEY constraint to the field of an existing MySQL table?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 2K+ Views

We can add a FOREIGN KEY constraint to a column of an existing MySQL table with the help of ALTER TABLE statement. Syntax ALTER TABLE table_name ADD FOREIGN KEY (colum_name) REFERENCES table having Primary Key(column_name); Example Suppose we want to add a FOREIGN KEY constraint on the table ‘Orders1’ referencing to the table ‘Customer’ which have column ‘Cust_Id’ as the Primary Key. It can be done with the help of the following query − mysql> Alter table orders1 add FOREIGN KEY(Cust_id) REFERENCES Customer(Cust_id); Query OK, 0 rows affected (0.21 sec) Records: 0  Duplicates: 0  Warnings: 0   mysql> ...

Read More

How can I fetch the value of REPLACE() function in the column name of our choice?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 147 Views

For fetching the values of REPLACE() function in our choice column name, we need to use the keyword ‘AS’ with REPLACE() function. Example mysql> Select Name, REPLACE(Name, 'G','S') AS Name_Changed from student Where Subject = 'Computers'; +--------+--------------+ | Name | Name_Changed | +--------+--------------+ | Gaurav | Saurav | | Gaurav | Saurav | +--------+--------------+ 2 rows in set (0.00 sec) The query above will give the result set of REPLACE() function in column name of our choice ‘Name_Changed’ which is given after keyword ‘AS’.

Read More

How MySQL behaves if I use INTERVAL keyword with an invalid date?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 210 Views

Actually, the behavior of MySQL depends upon the allow_invalid_dates mode. If this mode is enabled then MySQL will accept the invalid date and it would perform the date arithmetic as it performs with a valid date. Otherwise, if this mode is inactive then it will not accept the invalid date and would produce NULL as output. mysql> select '2017-02-30' + INTERVAL 7 day; +-------------------------------+ | '2017-02-30' + INTERVAL 7 day | +-------------------------------+ | NULL ...

Read More

What is function overloading in JavaScript?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 2K+ Views

JavaScript does not support Function Overloading. The following shows function overloading − function funcONE(x,y) { return x*y; } function funcONE(z) { return z; } The above will not show an error, but you won't get desired results. On calling, // prints 5 funcONE(5); // prints 5, not 30 funcONE(5,6); JavaScript does not support function overloading natively. If we will add functions with the same name and different arguments, it considers the last defined function.

Read More

How to use comments to prevent JavaScript Execution?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 337 Views

If you want another code while working in the same code document, then use comments. Comment the previous code and add the alternative code to test it. After the testing completes, uncomment the previous code. In this way, you can test both the codes. While using comments follow the below rules to create valid comments − Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript. Any text between the characters /* and */ is treated as a comment. This may span multiple lines. JavaScript also recognizes the ...

Read More

How to debug obfuscated JavaScript?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 672 Views

To debug obfuscated JavaScript code, you need to use a JavaScript formatter or beautifier. Go to the following link to beautify JavaScript, In the left section, add your obfuscated JavaScript code and click Beautify as shown below, On clicking, you can see Beautified JavaScript code in the right section.

Read More

How can I check how much time MySQL query, without printing it on the console, is taking?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 283 Views

To check this we need to have the profiling information which indicates resource usage for the statements executed during the course of the current session. Profiling information can get by SHOW PROFILE and SHOW PROFILES statement. Before running these statements, the profiling session variable must be set to 1 as follows − mysql> set profiling = 1; Query OK, 0 rows affected (0.00 sec) Now if we will run SHOW PROFILES statement then it will display the list of most recent statements sent to the server along with the duration and query id. mysql> show profiles; +----------+------------+--------------------------------------+ ...

Read More
Showing 21–30 of 45 articles
Advertisements