What will happen when we try to override final method of the superclass in Java?

raja
Updated on 30-Jul-2019 22:30:26

1K+ Views

Any method that is declared as final in the superclass cannot be overridden by a subclass. If we try to override the final method of super class we will get an error in Java.Rules for implementing Method OverridingThe method declaration should be the same as that of the method that is to be overridden.The class (subclass) should extend another class (superclass), prior to even try overriding.The Sub Class can never override final methods of the Super Class.ExampleLive Democlass Car {    public void brake() {       System.out.println("brake() method of Car");    }    public final void accelerate() {       ... Read More

What is the importance of _isEqual() method in JavaScript?

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

968 Views

_isEqual() _isEqual() is from the underscore and lodash library of javascript. It is used to compare javascript objects. The importance of this method is that it doesn't care about the order of properties while comparing the objects. It only checks whether the properties in the two objects are equal or not. Whereas JSON.stringify(), which is used in comparing the objects, checks even the order of properties of the objects, making _isEqual() the better option. syntax_.isEqual(object1, object2);It accepts two objects as parameters and scrutinizes whether they are equal or not.ExampleLive Demo    var obj1 = {name: "Sikha", designation: "Content developer"}; ... Read More

How to combine two tables and add a new column with records in MySQL?

Rama Giri
Updated on 30-Jul-2019 22:30:26

438 Views

Let us first create a table −mysql> create table DemoTable1    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(100)    -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(Name) values('Chris'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1(Name) values('Robert'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;Output+----+--------+ | Id | Name   | +----+--------+ |  1 | Chris  | |  2 | Robert | +----+--------+ 2 ... Read More

Add N digits to A such that it is divisible by B after each addition in C++?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

111 Views

Here we will see how to generate a number A by adding N digits with it, and while adding new digits in each stage it will be divisible by another number B. Let us consider we are going to make a 5-digit number by adding 4 extra digits with it. We will check the divisibility by 7. The number will start from 8. So at first it will append 4 with it, so the number will be 84, that is divisible by 7. Then add 0 with the number so it will remain divisible by 7. If the number cannot ... Read More

HTML DOM lastElementChild Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

31 Views

The HTML DOM lastElementChild property returns the last element node as node object of the specified node.NOTE − This property does ignore text and comment nodesSyntaxFollowing is the syntax −Returning lastElementChild nodenodeList.lastElementChildExampleLet us see an example for HTML DOM lastElementChild property − Live Demo HTML DOM lastElementChild    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    }    ul{       width: 30%; ... Read More

What is a free function in C++?

Anvi Jain
Updated on 30-Jul-2019 22:30:26

269 Views

The C/C++ library function void free(void *ptr) deallocates the memory previously allocated by a call to calloc, malloc, or realloc. Following is the declaration for free() function.void free(void *ptr)This function takes a pointer ptr. This is the pointer to a memory block previously allocated with malloc, calloc or realloc to be deallocated. If a null pointer is passed as argument, no action occurs.Example#include #include #include using namespace std; int main () {    char *str;    /* Initial memory allocation */    str = (char *) malloc(15);    strcpy(str, "tutorialspoint");    cout

How to display the first element in a JComboBox in Java

Nancy Den
Updated on 30-Jul-2019 22:30:26

528 Views

To display the first element in a JComboBox, use the getSelectedIndex():comboBox.setSelectedIndex(0);The following is an example to display the first element in a JComboBox in Java:Exampleimport java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; public class SwingDemo {    public static void main(String[] args) {       JPanel panel = new JPanel(new BorderLayout());       String[] strArr = new String[] { "Laptop", "Mobile", "Desktop", "Tablet" };       JComboBox comboBox = new JComboBox(strArr);       panel.add(comboBox, BorderLayout.NORTH);       JTextArea text = new JTextArea(5, 5);       panel.add(text, ... Read More

How to close the notification panel after notification button is clicked in Android?

Anvi Jain
Updated on 30-Jul-2019 22:30:26

1K+ Views

This example demonstrate about How to close the notification panel after notification button is clicked in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.content.Context ; import android.content.Intent ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import android.widget.Button ; public class MainActivity extends AppCompatActivity { ... Read More

IPC using Message Queues

George John
Updated on 30-Jul-2019 22:30:26

3K+ Views

Why do we need message queues when we already have the shared memory? It would be for multiple reasons, let us try to break this into multiple points for simplification −As understood, once the message is received by a process it would be no longer available for any other process. Whereas in shared memory, the data is available for multiple processes to access.If we want to communicate with small message formats.Shared memory data need to be protected with synchronization when multiple processes communicating at the same time.Frequency of writing and reading using the shared memory is high, then it would ... Read More

How to set the alignment of the JLabel content along the Y axis on the top in Java

Smita Kapse
Updated on 30-Jul-2019 22:30:26

108 Views

To set the alignment of the label’s content along the Y axis on the top, use the setVerticalAlignment() method and set the location. Let us first set a label component. We have set the label background color as well so that we can check the alignment of the label’s content properly −JLabel label = new JLabel("Favourite Movie"); label.setPreferredSize(new Dimension(190, 100)); label.setOpaque(true); label.setBackground(Color.GREEN); label.setForeground(Color.WHITE);Now, we will align the label content along the Y axis on the top by seeting location as TOP −label.setVerticalAlignment(JLabel.TOP);The following is an example to set the alignment of the JLabel content along the Y axis on the ... Read More

Advertisements