Found 9150 Articles for Object Oriented Programming

How to add an element to a JavaScript object?

Vivek Verma
Updated on 02-Sep-2023 11:27:38

74K+ Views

In JavaScript, the object is a real-time entity that contains properties and methods. In simple words, we can say that object is an instance of a class. It stores the data in the form of key and value pairs. The keys are usually referred to as properties and the values are referred to as property values. There are two ways to define an object in JavaScript. Syntax var obj = new Object(); (or) var obj = {property1: value, property2 : value2 …….} Using dot (.) operator In JavaScript, using the dot (.) operator we can access a variable ... Read More

Write a number array and add only odd numbers?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

1K+ Views

Odd number summation using JavaScript. Live DemoExample var tot = 0; var a = [1,45,78,9,78,40,67,76]; for(var i = 0; i

Explain about add and assignment(+=) operator in detail in javascript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

198 Views

add and assignment(+=) operatorThe add and assignment(+=) operator reduces the code little bit.It may not much influential  in small codes whereas coming to long codes it's use can't be ignored. Live DemoExample    var tot = 0;    var a = [1,45,78,9,78,40];    for(var i = 0; i

Explain about logical not(!) operator in detail with example in javascript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

159 Views

NOT operatorThe logical NOT operator gives true for false values and false for true values. Live DemoExample var x = 200; var y = 300; document.getElementById("logical").innerHTML = !(x < y) + "" + !(x > y); Outputfalse true

what is the significance of finally in javascript?

Abdul Rawoof
Updated on 25-Aug-2022 12:19:24

1K+ Views

In JavaScript finally is a block of code or statements that are executed in all cases while handling errors with a try and catch block whenever used. These try, catch and finally blocks in JavaScript will execute the code that is prone to error and may cause the program to behave incorrectly (terminate abruptly). This finally block is positioned after the try and catch blocks, will unquestionably be executed if either of those blocks, try or catch, is ever executed. The finally block allows us to define the actions that must be performed regardless of whether some code succeeds or ... Read More

what is the main difference between '=' and '==' operators in javascript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

247 Views

The use of  "=" operator is that it assigns value from right to left, whereas "==" shows whether the given values are equal or not.In the following example variables x and y were assigned values using "=" operator and their magnitudes were checked using "==" operator.Example Live Demo    var x = 5;    var y = "6";    document.write(x);    document.getElementById("equal").innerHTML =    (x == y); Outputfalse 5

Write the main difference between '==' and '===' operators in javascript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

179 Views

The difference between '==' and '===' is that former checks only value but the latter checks value and also data type(String, Boolean etc).The following example gives whether values assigned are equal or not irrespective of datatype. a) "==" operator(checks equality) Example Live Demo    var x = 5;    var y = 5;    var z = 6;    document.getElementById("strict").innerHTML =    (x == y) + "" + (x == z); Outputtrue falseb) '===' operator (Checks strict equality)     "==="  operator gives true if and only if both value and data type are equal.If not it returns false.In ... Read More

How to count rows – count (*) and Java

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

10K+ Views

The SQL Count() function returns the number of rows in a table. Using this you can get the number of rows in a table.select count(*) from TABLE_NAME;Let us create a table with name cricketers_data in MySQL database using CREATE statement as shown below −CREATE TABLE cricketers_data(    First_Name VARCHAR(255),    Last_Name VARCHAR(255),    Date_Of_Birth date,    Place_Of_Birth VARCHAR(255),    Country VARCHAR(255), );Now, we will insert 5 records in cricketers_data table using INSERT statements −insert into cricketers_data values('Shikhar', 'Dhawan', DATE('1981-12-05'), 'Delhi', 'India'); insert into cricketers_data values('Jonathan', 'Trott', DATE('1981-04-22'), 'CapeTown', 'SouthAfrica'); insert into cricketers_data values('Kumara', 'Sangakkara', DATE('1977-10-27'), 'Matale', 'Srilanka'); insert into cricketers_data values('Virat', 'Kohli', DATE('1988-11-05'), 'Delhi', ... Read More

Can we return Result sets in JDBC?

Rishi Raj
Updated on 30-Jul-2019 22:30:26

1K+ Views

Yes, just like any other objects in Java we can pass a ResultSet object as a parameter to a method and, return it from a method.Let us create a table with name MyPlayers in MySQL database using CREATE statement as shown below −CREATE TABLE MyPlayers(    ID INT,    First_Name VARCHAR(255),    Last_Name VARCHAR(255),    Date_Of_Birth date,    Place_Of_Birth VARCHAR(255),    Country VARCHAR(255),    PRIMARY KEY (ID) );Now, we will insert 7 records in MyPlayers table using INSERT statements −insert into MyPlayers values(1, 'Shikhar', 'Dhawan', DATE('1981-12-05'), 'Delhi', 'India'); insert into MyPlayers values(2, 'Jonathan', 'Trott', DATE('1981-04-22'), 'CapeTown', 'SouthAfrica'); insert into MyPlayers values(3, 'Kumara', 'Sangakkara', ... Read More

How to delete all records from a table in Oracle using JDBC API?

Rishi Raj
Updated on 30-Jul-2019 22:30:26

2K+ Views

The SQL TRUNCATE statement is used to delete all the records from a table.SyntaxTRUNCATE TABLE table_name;To delete all the records from a table from using JDBC API you need to −Register the Driver: Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.Establish a connection: Connect to the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.Create Statement: Create a Statement object using the createStatement() method of the Connection interface.Execute the Query: Execute the query using the execute() method of the Statement interface.Following JDBC program ... Read More

Advertisements