To delete specific record, use $pull operator. Let us first create a collection with documents −> dbdeletingSpecificRecordDemoinsertOne( { "StudentDetails": [ { "StudentName": "John", "StudentSubjectDetails": [ { "Subject": "MongoDB", "Marks":45 }, { "Subject": ... Read More
The readonly attribute of the element is used to set a textarea as readonly. The visitor cannot change the text in the textarea if it is set as readonly.However, visitor can copy that content.Following is the syntax −Let us now see an example to implement the readonly attribute of the element −Example Live Demo Interview Questions Q1 Q2 Guidelines to appear for interview: The interviewee should reach at 10AM with the certificates. OutputIn the above example, we have 3 ... Read More
The class named Types of the java.sql package contains the constants that represents the SQL datatypes. All these datatypes are represented by unique integer values.Retrieving the integer values from the Types classTo print all the class names and values of the constants in java.sql.Types class −Retrieve all the fields in Types class − The getFields() method of the class Class returns an array which holds all the fileds (public) of the class/interface represented by the current Class object.Using this method retrieve the array of fileds of the Types class as shown below −Field[] fields = java.sql.Types.class.getFields();Retrieve the name and value ... Read More
Following is a Java program to print the spiral form of a given matrix.Example Live Demopublic class PrintMatrixInSpiralForm { public static void main(String args[]){ int a[][]={{1,2,3},{4,5,6},{7,8,9}}; int w = 0; int x = a.length-1; int y = 0; int z = a[0].length-1; while(w
To check whether a number is palindrome or not, we have to reverse the number, and then if the actual number and the reversed number are same, then this is palindrome. In Bash, performing the reverse operation is very easy. We have to use the ‘rev’ command to do that. Let us see the program to understand clearly.Example#!/bin/bash # GNU bash Script n=12321 rev=$(echo $n | rev) if [ $n -eq $rev ]; then echo "Number is palindrome" else echo "Number is not palindrome" fioutlineNumber is palindrome
In C++, we can instantiate the class object with or without using the new keyword. If the new keyword is not use, then it is like normal object. This will be stored at the stack section. This will be destroyed when the scope ends. But for the case when we want to allocate the space for the item dynamically, then we can create pointer of that class, and instantiate using new operator.In C++, the new is used to dynamically allocate memory.Example#include using namespace std; class Point { int x, y, z; public: Point(int x, ... Read More
Python's interactive mode works on the principle of REPL (Read - Evaluate - Print - Loop). The code module in Python's standard library provides classes nd convenience functions to set up REPL environment from within Python script.Following two classes are defined in code module:InteractiveInterpreter: This class deals with parsing and interpreter state (the user’s namespace)InteractiveConsole: Closely emulate the behavior of the interactive Python interpreter.Two convenience functions in the module are:interact(): Convenience function to run a read-eval-print loop.compile_command(): This function is useful for programs that want to emulate Python’s interpreter main loop (the REPL).Interactive Interpreter methodsrunsource(): Compile and run some source ... Read More
In wireless LANs (wireless local area networks), the exposed terminal problem is a transmission problem that arises when a transmitting station is prevented from sending frames due to interference with another transmitting station. This is prevalent in decentralised systems where there aren’t any entity for controlling transmissions. This occurs when a station is visible from a wireless access point (AP), but not from other stations that communicate with the AP.Problem IllustrationSuppose that there are four stations labelled STA, STB, STC, and STD, where STB and STC are transmitters while STA and STD are receivers at some slot of time. The ... Read More
To get the number of levels above a node, use the getLevel() method. Following is an example for the root node “node” −node.getLevel()Note − The value 0 is returned if the node is a root node since there are zero levels above the root node.For other nodes, get the number of levels above a node as shown below with node3 −node3.getLevel()The following is an example to get the number of levels above a node in a JTree −package my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class SwingDemo { public static void main(String[] args) throws Exception { ... Read More
Let us first create a collection with documents −> dbworkingOfRegularExpressionDemoinsertOne({ "StudentDetails" : { "StudentName" : "John" }, "StudentAge":21 }); { "acknowledged" : true, "insertedId" : ObjectId("5cf227acb64a577be5a2bc07") } > dbworkingOfRegularExpressionDemoinsertOne({ "StudentDetails" : { "StudentName" : "JOHN" }, "StudentAge":19 }); { "acknowledged" : true, "insertedId" : ObjectId("5cf227b8b64a577be5a2bc08") } > dbworkingOfRegularExpressionDemoinsertOne({ "StudentDetails" : { "StudentName" : "Carol" }, "StudentAge":20 }); { "acknowledged" : true, "insertedId" : ObjectId("5cf227c2b64a577be5a2bc09") }Following is the query to display all documents from a collection with the help of find() method −> dbworkingOfRegularExpressionDemofind();This will produce the following document −{ "_id" : ObjectId("5cf227acb64a577be5a2bc07"), "StudentDetails" : ... Read More