Minggu, 02 April 2017

How scope and life of variables differ in class and globally

Scope of a variable refers to in which areas or sections of a program can the variable be accessed and lifetime of a variable refers to how long the variable stays alive in memory. General convention for a variable’s scope is, it is accessible only within the block in which it is declared. A block begins with a left curly brace { and ends with a right curly brace }. As we know there are three types of variables: 1) instance variables, 2) class variables and 3) local variables, we will look at the scope and lifetime of each of them now.

The post How scope and life of variables differ in class and globally appeared first on Coding Security.


How scope and life of variables differ in class and globally
read more

What are different event listener classes in java events

ActionListener  This interface deals with the action events. Following is the event handling method available in the ActionListener interface: void actionPerformed(ActionEvent ae)   AdjustmentListener This interface deals with the adjustment event generated by the scroll bar. Following is the event handling method available in the AdjustmentListener interface: void adjustmentValueChanged(AdjustmentEvent ae)   ComponentListener This interface deals with the component events. Following are the event handling methods available in the ComponentListener interface: void componentResized(ComponentEvent ce) void componentMoved(ComponentEvent ce) void componentShown(ComponentEvent ce) void componentHidden(ComponentEvent ce)   ContainerListener This interface deals with the events that can be generated on containers. Following are the event

The post What are different event listener classes in java events appeared first on Coding Security.


What are different event listener classes in java events
read more

How to suspend and resume threads in java programming

Based on the requirements sometimes you might want to suspend, resume or stop a thread. For doing such operations on a thread, before Java 2, thread API used to contain suspend(), resume() and stop() methods. But all these methods might lead to undesired behavior of the program or machine. For example, these methods might lead to deadlock when a thread locked and is accessing a data structure and suddenly it is suspended or stopped. All other threads will be waiting indefinitely for gaining access to the data structure. Because of this drawback of suspend(), resume() and stop() methods, they have been deprecated (should not

The post How to suspend and resume threads in java programming appeared first on Coding Security.


How to suspend and resume threads in java programming
read more

Sabtu, 01 April 2017

What are PreProcessors Operations in C Programming

Stringizing Operator # ANSI C provides an operator # called stringizing operator to be used in the definition of macro functions. This operator converts a formal argument into a string. For example, if the macro is defined as follows: 1 #define     sum(xy)     printf(#xy  “ = %f \n”, xy) and somewhere in the program the statement is written as: sum(a+b); then the preprocessor converts this line as shown below: 1 printf(“a+b”  “ = %f \n”, a+b); Token Pasting Operator ## The token pasting operator ## defined by ANSI enables us to combine two tokens within a macro definition to form a single token.

The post What are PreProcessors Operations in C Programming appeared first on Coding Security.


What are PreProcessors Operations in C Programming
read more

How to work with nested interfaces in java programming

An interface which is declared inside a class or another interface is called a nested interface or a member interface. A nested interface can be declared as public, private or protected. Let’s look at an example of how to create and use a nested interface: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 class A { int x; public interface IA { void method(); } } class B implements A.IA { public void method() { System.out.println(“Method implemented successfully”); } } public class Driver { public static void main(String args)

The post How to work with nested interfaces in java programming appeared first on Coding Security.


How to work with nested interfaces in java programming
read more

What are the methods to modify object class in java

In Java the base class or parent class or super class for all other classes is the Object class. This Object class provides the common functionality for all other objects.   Object Class Methods Following are different methods provided by the Object class: clone() method This method is used to create a new object which is same as the object being cloned. Syntax of this method is as follows: Object clone() equals() method This method is used to determine whether one object is same as the other object. Syntax of this method is as follows: boolean equals(Object obj) finalize() method This method is

The post What are the methods to modify object class in java appeared first on Coding Security.


What are the methods to modify object class in java
read more

Jumat, 31 Maret 2017

How to refer super class members in C++ using super keyword

Second use of super keyword (in sub class) is to access the hidden members of its immediate super class. To understand this let’s consider the following example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 class A { int x; public void display() { System.out.println(“This is display in A”); } } class B extends A { int x; public void display() { System.out.println(“Value of x in A is: “ + super.x); super.display(); System.out.println(“This is display in B”); } } class Driver {

The post How to refer super class members in C++ using super keyword appeared first on Coding Security.


How to refer super class members in C++ using super keyword
read more