- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
In this section, we will see one interesting problem. There are N coins. we have to find what is the max height we can make if we arrange the coins as pyramid. In this fashion, the first row will hold 1 coin, second will hold 2 coins and so on.In the given diagram, we can see to make a pyramid of height three we need minimum 6 coins. We cannot make height 4 until we have 10 coins. Now let us see how to check the maximum height.We can get the height by using this formula.Example Live Demo#include #include using namespace ... Read More
Object slicing is used to describe the situation when you assign an object of a derived class to an instance of a base class. This causes a loss of methods and member variables for the derived class object. This is termed as information being sliced away. For example, class Foo { int a; }; class Bar : public Foo { int b; }Since Bar extends Foo, it now has 2 member variables, a and b. So if you create a variable bar of type Bar and then create a variable of type Foo and assign bar, you'll lose ... Read More
Here we will see how to hide some string into some binary code (Here binary code is represented in hexadecimal number).The approach is very simple. We can use the string stream to convert decimal number to hexadecimal numbers. Now from the string, we will read each character, and take its ASCII value, these ASCII values are converted into hexadecimal values. Then we can print them one by one.Example#include #include using namespace std; string dec_to_hex(int decimal){ //function is used to convert decimal to hex stringstream my_ss; my_ss
Generally, Data about data is known as metadata. The DatabaseMetaData interface provides methods to get information about the database you have connected with like, database name, database driver version, maximum column length etc...The getMetaData() method of the Connection interface retrieves and returns the DatabaseMetaData object. This contains information about the database you have connected to. You can get information about the database such as name of the database, version, driver name, user name and, url etc… by invoking the methods of the DatabaseMetaData interface using the obtained object.This method returns the DatabaseMetaData object which holds information about the underlying database.To get ... Read More
The statement db.collection.find() returns the cursor of Result Set of a query by which you can iterate over the result set or print all documents.Let us first create a collection with documents −> db.findCursorDemo.insertOne({"ClientFirstName":"John", "ClientLastName":"Smith"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd00a1c588d4a6447b2e05c") } > db.findCursorDemo.insertOne({"ClientFirstName":"Carol", "ClientLastName":"Taylor"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd00a26588d4a6447b2e05d") } > db.findCursorDemo.insertOne({"ClientFirstName":"David", "ClientLastName":"Miller"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd00a33588d4a6447b2e05e") }Following is the query to display all documents from a collection with the help of find() method −> db.findCursorDemo.find();This will produce the following output −{ "_id" : ObjectId("5cd00a1c588d4a6447b2e05c"), "ClientFirstName" : ... Read More
The DefaultTableModel is an implementation of TableModel that uses a Vector of Vectors to store the cell value objects. At first create a two dimensional array for rows and columns −DefaultTableModel tableModel = new DefaultTableModel(new Object[][] { { "India", "Asia" }, { "Canada", "North America" }, { "Singapore", "Asia" }, { "Malaysia", "Asia" }, { "Philippins", "Asia" }, { "Oman", "Asia" }, { "Germany", "Europe" }, { "France", "Europe" } }, new Object[] { "Country", "Continent" });Above, “Country” and “Continent” are the columns. Now, set the above set of rows and columns to JTable −JTable table = ... Read More
To generate ObjectID, use the below syntax in the MonogDB shell −new ObjectId()Let us implement the above syntax to generate ObjectID in MongoDB −> new ObjectId() ObjectId("5cd7bf2f6d78f205348bc646") > new ObjectId() ObjectId("5cd7bf316d78f205348bc647") > new ObjectId() ObjectId("5cd7bf336d78f205348bc648") > new ObjectId() ObjectId("5cd7bf346d78f205348bc649") > new ObjectId() ObjectId("5cd7bf356d78f205348bc64a") > new ObjectId() ObjectId("5cd7bf396d78f205348bc64b") > new ObjectId() ObjectId("5cd7bf3a6d78f205348bc64c")As shown above, every time you will get a new ObjectId.
Yes, We can create a generator by using iterators in python Creating iterators is easy, we can create a generator by using the keyword yield statement. Python generators are an easy and simple way of creating iterators. and is mainly used to declare a function that behaves like an iterator.The generator is a function which we can iterate over one value at a time most probably in a day to day life, every programmer will use iterable objects like lists, strings, and Dict, etc. An iterator is an object that can be iterated through looping.The following example shows that Generators introduce Yield ... Read More
Keywords − Keywords in Java convey a special meaning to the compiler therefore, these cannot be used as identifiers. Java provides a set of 50 keywords.abstractcontinuefornewswitchassertdefaultgotopackagesynchronizedbooleandoifprivatethisbreakdoubleimplementsprotectedthrowbyteelseimportpublicthrowscaseenuminstanceofreturntransientcatchextendsintshorttrycharfinalinterfacestaticvoidclassfinallylongstrictfpvolatileconstfloatnativesuperwhileReserved words − Among the list of key words list mentioned above the key words goto and const are currently not in use. They are reserved words (for the future use).The true false and null − True, false and null represents certain values in Java, they are used as literals. They are not considered as keywords.Still, you cannot use them as identifiers in Java if you try to do so, a compile time error will ... Read More
The HTML DOM select Object represent the element of an HTML document.Let’s see how to create select objectSyntaxFollowing is the syntax −document.createElement(“SELECT”);PropertiesFollowing are the properties of select Object −PropertyExplanationautofocusIt returns and modify whether the drop-down list should get focused or not when page load.disabledIt returns and modify whether the drop-down list is disabled or not.lengthIt returns the number of elements inside a drop-down list in an HTML document.formIt returns the reference of the form that contain the drop-down list in the HTML document.multipleIt returns and modify whether multiple options can be selected from a drop-down list or not.nameIt returns ... Read More
To Continue Learning Please Login
Login with Google