In C and C++ there are some function specifiers. The function specifiers are used to specify the functions property. C++ has inline function specifier. In C there is _Noreturn function specifier. This is used to denote that one function will not return anything.Example Live Demo#include int myAdd(int a, int b){ return a + b; } main() { int x = 10, y = 20; printf("The value is: %d", myAdd(x, y)); }OutputThe value is: 30If the _Noreturn is used it will display some warning and the program will be terminated with some error.Example#include _Noreturn int myAdd(int a, int b){ ... Read More
You can get the column count in a table using the getColumnCount() method of the ResultSetMetaData interface. On invoking, this method returns an integer representing the number of columns in the table in the current ResultSet object.//Retrieving the ResultSetMetaData object ResultSetMetaData rsmd = rs.getMetaData(); //getting the column type int column_count = rsmd.getColumnCount();Let us create a table with name employee_data in MySQL database using CREATE statement as shown below −CREATE TABLE employee_data( id INT, Name VARCHAR(255), DOB date, Location VARCHAR(40) );Following JDBC program establishes connection with the database, retrieves the ResultSetMetaData object of the employee_data table, and prints the number of columns in it.Exampleimport ... Read More
Accessing Property Of An ObjectWithout objects there is no JavaScript. Everything such as boolean,numbers,functions etc are all objects.Accessing properties of an object is explained in the following method.Example-1 Live Demo myObj = {"name":"Ramesh","age":30,"family": [{"mother":"Geetha","father":"Rao"}],"city":"Berlin"}; var res = myObj.family[0].mother; document.write(res); OutputGeethaExample-2 Live Demo myObj = {"name":"Ramesh","age":30,"family": [{"mother":"Geetha","father":"Rao"}],"city":"Berlin"}; var res = myObj.city; document.write(res); OutputBerlin
To create and set empty border to a component, use the BorderFactory class createEmptyBorder() method −EmptyBorder emptyBorder = (EmptyBorder) BorderFactory.createEmptyBorder();To set the above border to a component, use the setBorder() method −JButton button = new JButton("Empty Border"); button.setBorder(emptyBorder);The following is an example to create and set and empty border from BorderFactory class −package my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.border.SoftBevelBorder; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ... Read More
Let’s say the following is our table −String[][] rec = { { "1", "Steve", "AUS" }, { "2", "Virat", "IND" }, { "3", "Kane", "NZ" }, { "4", "David", "AUS" }, { "5", "Ben", "ENG" }, { "6", "Eion", "ENG" }, }; String[] header = { "Rank", "Player", "Country" }; JTable table = new JTable(rec, header);Prevent displaying grid lines −table.setShowGrid(false);The following is an example to prevent displaying grid lines −Examplepackage my; import java.awt.Color; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.border.TitledBorder; public class SwingDemo { public static void main(String[] ... Read More
To find the greatest value among four tables, you can use the method GREATEST(). Following is the query to create first table −mysql> create table DemoTable1 -> ( -> Value int -> ); Query OK, 0 rows affected (0.70 sec)Insert some records in the first table using insert command −mysql> insert into DemoTable1 values(10); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1 values(60); Query OK, 1 row affected (0.14 sec)Display all records from the first table using select statement −mysql> select *from DemoTable1;Output+-------+ | Value | +-------+ | 10 | ... Read More
Here we will see the kbhit functionality in C. The kbhit is basically the Keyboard Hit. This function is present at conio.h header file. So for using this, we have to include this header file into our code.The functionality of kbhit() is that, when a key is pressed it returns nonzero value, otherwise returns zero.Example#include #include main() { char ch; printf("Enter keys (ESC to exit)"); while (1) { //define infinite loop for taking keys if (kbhit) { ch = getch(); // Get typed character into ch ... Read More
In C++ we can use the function overloading feature. Using this feature, we can create functions with same name. The only difference is the type of the arguments, and the number of arguments. The return type is not considered here. Now the question comes how the C++ distinguishes overloaded functions in object code?In the object code, it changes the name by adding information about the arguments. The technique which is applied here is called the Name Mangling. C++ has no standardized technique for name mangling. So different compiler uses different techniques.Here is an example of Name Mangling. The overloaded functions ... Read More
Whenever we execute SQL statements using the executeQuery() method, it returns a ResultSet object which holds the tabular data returned by the SELECT queries(in general). The ResultSet object contains a cursor/pointer which points to the current row. Initially this cursor is positioned before first row (default position).The ResultSet interface provides various methods to find, the no.of columns, name of the column, type of the column etc.. but, it does not provides any method to find the number of rows in a table directly.Using count(*) function in the SELECT query you can get the number of rows in a table as −select ... Read More
You can use $pull operator. Let us first create a collection with documents −> db.pullAnArrayElementDemo.insertOne( { "StudentDetails": [ { "StudentFirstName":"Chris", "StudentScore":56 }, {"StudentFirstName":"Robert", "StudentScore":59 } ] } ); { "acknowledged" : true, "insertedId" : ObjectId("5cd3b55bedc6604c74817cd5") }Following is the query to display all documents from a collection with the help of find() method −> db.pullAnArrayElementDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cd3b55bedc6604c74817cd5"), "StudentDetails" : [ { "StudentFirstName" : "Chris", "StudentScore" : 56 }, { ... Read More