FIELD DECLARATION IN JAVA

Field Declarations in Classes:

The purpose of a field is to hold a value inside an object or a class . A field must be declared in a class declaration. A field-declaration has one of the forms

field-modifiers type fieldnamel, fieldname2,...;
field-modifiers type fieldnamel = initializer1,...;

The field-modifiers may be a list of the modifiers static, final, transient and volatile and at most One of the access modifiers private, protected, and public .

If a field f in class C is declared static, then f is associated with the class C and can be referred to independently of any objects of class C. The field can be referred to as C.f or o.f, where o is an expression of type C, or, in the declaration of C, as f. If a field f in class C is not declared static, then f is associated with an object (also called instance) of class C, and every instance has its own instance of the field. The field can be referred to as o.f, where o is an expression of type C, or, in nonstatic code in the declaration of C, as f.

If a field f in class C is declared final, the field cannot be modified after initialization. If f has
reference type and points to an object or array, the object's fields or the array's elements may still be modified. The initialization must happen either in the declaration or in an initializer block ,
or (if the field is nonstatic) precisely once in every constructor in class C.A field initializer may be an expression or an array initializer . A static field initializer can refer only to static members of C and can throw no checked exceptions.

A field is given a default initial value depending on its type t. If t is a primitive type, the field is initialized to 0 (when t is byte, char, short, int, or long) or 0.0 (when t is float or double) or false (when t is boolean). If t is a reference type, the field is initialized to null.

Static fields are initialized when the class is loaded. First all static fields are given their default initial values, then the static initializer blocks static field initializers are executed, in order of
appearance in the class declaration.

Non static fields are initialized when a constructor is called, at which time all static fields have been initialized already .

If a class C declares a non static field f, and C is a subclass of a class B that has a non static field f, then every object of class C has two fields, both called f: one is the B-field f declared in the superclass B, and one is the C-field f declared in C itself. What field is referred to by a field access o.f is determined by the type of o .

The Member Access Modifiers :private, protected, public

The access modifiers private, protected, and public determine where else the member is accessible.If a member is declared private in top-level class C or a nested class within C, it is accessible in C and its nested classes, but not in their subclasses outside C nor in other classes.

If a member in class C is declared protected, it is accessible in all classes in the same package C and in subclasses of C, but not in non-subclasses in other packages. If a member in class C is not declared private, protected,or public, it has package access,or default access, and is accessible only in classes within the same package as C, not in classes in other packages.

If a member in class C is declared public, it is accessible in all classes, including classes in other packages. Thus, in order of increasing accessibility, we have private access, package (or default) access, protected access, and public access.

Private Member Accessibility:

A private member is accessible everywhere inside the enclosing top-level class (and only there).

class Access {
private static int x;
static class SI {
private static int y = x;
Access private x from enclosing class
}
static void m() {
int z = SI.y;
Access private y from nested class
}
}

Method Declarations:
A method must be declared inside a class. A method-declaration declaring method m has the form method-modifiers return-type m (formal-list) throws-clause
method-body
The formal-list is a comma-separated list of zero or more formal parameter declarations, of form
parameter-modifier type parameter-name

The parameter-modifier may be final, meaning that the parameter cannot be modified inside the method, or absent. The type is any type. The parameter-name is any name, but the parameter names must be distinct. A formal parameter is an initialized variable; its scope is the method -body.The method name m together with the list t1,..., tn of declared parameter types in the formal-list determine the method signature m(t1,..., tn). The return-type is not part of the method signature.


A class may declare more than one method with the same method-name, provided they have different method signatures. This is called overloading of the method-name. The method-body is a block-statement and thus may contain statements as well as declarations of variables and local classes. In particular, the method-body may contain return statements.

If the return-type is void, the method does not return a value, and no return in method-body can have an expression argument. If the return-type is not void but a type, the method must return a value: it must not be possible for execution to reach the end of method-body without executing a return statement. Moreover, every return statement must have an expression
argument whose type is a subtype of the return-type.

The method-modifiers may be abstract or a list of static, final, synchronized ,and at most one of the access modifiers private, protected, and public .If a method m in class C is declared static, then m is associated with the class C; it can be referred to without any object. The method may be called as C.m(...) or as o.m(...), where o is an expression whose type is a subtype of C, or, inside methods, constructors, field initializers, and initializer blocks in C, simply as m(...).

A static method can refer only to static fields and methods of the class.If a method m in class C is not declared static, then m is associated with an object (instance) of class C. Outside the class, the method must be called as o.m(...), where o is an object of class C or a subclass, or, inside non static methods, non static field initializers, and non static initializer blocks in C,simply as m(...). A non static method can refer to all fields and methods of class C, whether they are static or not.

If a method m in class C is declared final, it cannot be overridden (redefined) in subclasses.
If a method m in class C is declared abstract, class C must itself be abstract (and so cannot be
instantiated). An abstract method cannot be static, final, or synchronized, and its declaration
has this form, without a method body:

abstract method-modifiers return-type m(formal-list) throws-clause;

The throws-clause of a method or constructor has the form throws E1, E2, ...
where El, E2,... are the names of exception types covering all the checked exceptions that the method or constructor may throw. If execution may throw exception e, then e is either an unchecked exception or a checked exception whose class is a subtype of one of El, E2,....

Method Name Overloading and Signatures in java:

This class declares four overloaded methods m whose signatures m(int) and m(boolean) and m(int, double) and m(double, double). Some of the overloaded methods are static, others non static. The overloaded methods may have different return types, as shown here.

It would be legal to declare an additional method with signature m(double, int), but then the method call m(10, 20) would become ambiguous and illegal. Namely, there is no way to determine whether to call m(int, double) or m(double, int).

class Overloading {

double m(int i) {
return i;
}

boolean m(boolean b) {
return !b;
}

static double m(int x, double y) {
return x + y + 1;
}

static double m(double x, double y) {
return x + y + 3;
}

public static void main(String[] args) {
System.out.println(m(10, 20)); output is Prints: 31.0
System.out.println(m(10, 20.0)); output is Prints: 31.0
System.out.println(m(10.0, 20)); output is Prints: 33.0
System.out.println(m(10.0, 20.0)); output is Prints: 33.0
}
}

Method Overriding and Overloading in java:
The class C1 declares the overloaded method ml with signatures ml(double) and ml(int), and the
method m2 with signature m2(int). The subclass C2 hides C1's method ml(double) and overloads m2 by declaring an additional variant.

class Cl {
static void ml(double d) {
System.out.println("lld"); }

void ml(int i) {
System.out.println("lli"); }

void m2(int i) {
System.out.println("12i"); }
}

class C2 extends C1 {
static void ml(double d) {
System.out.println("21d"); }

void ml(int i) {
System.out.println("21i"); }

void m2(double d) {
System.out.println("22d"); }
}

int i = 17;
double d = 17.0;
C2 c2 = new C2(); Type C2, object class C2
C1 c1 = c2; Type C1, object class C1
c1.m1(i);
c2.m1(i);
c1.m1(d);
c2.m1(d);
c1.m2(i);
output isPrints: 21i ,21i, 11d, 21d, 12i.

RELATED POST

CONSTRUCTORS IN JAVA

DOT NET FAQ'S ON GARBAGE COLLECTION

What is Delay signing ?

During development process you will need strong name keys to be exposed to developer which
is not a good practice from security aspect point of view.In such situations you can assign the key
later on and during development you an use delay signing

Following is process to delay sign an assembly:

√ First obtain your string name keys using SN.EXE.

√ Annotate the source code for the assembly with two custom attributes from System.Reflection: AssemblyKeyFileAttribute, which passes the name of the file containing the public key as a parameter to its constructor. AssemblyDelaySignAttribute, which indicates that delay signing, is being used by passing true as a parameter to its constructor. For example as shown below:

[Visual Basic]




[C#]

[assembly:AssemblyKeyFileAttribute("myKey.snk")]
[assembly:AssemblyDelaySignAttribute(true)]

The compiler inserts the public key into the assembly manifest and reserves space in the PE file for the full strong name signature. The real public key must be stored while the assembly is built so that other assemblies that reference this assembly can obtain the key to store in their own assembly reference.

√ Because the assembly does not have a valid strong name signature, the verification of that signature must be turned off. You can do this by using the –Vr option with the Strong Name tool.The following example turns off verification for an assembly called myAssembly.dll.

Sn –Vr myAssembly.dll

Just before shipping, you submit the assembly to your organization's signing authority for the actual strong name signing using the –R option with the Strong Name tool.

The following example signs an assembly called myAssembly.dll with a strong name using the sgKey.snk key pair.

Sn -R myAssembly.dll sgKey.snk

What is garbage collection?

Garbage collection is a CLR feature which automatically manages memory. Programmers forget
to release the objects while coding ..... Laziness (Remember in VB6 where one of the good practices is to set object to nothing). CLR automatically releases objects when they are no longer in use and refernced. CLR runs on non-deterministic to see the unused objects and cleans them. One side effect of this non-deterministic feature is that we cannot assume an object is destroyed when it goes out of the scope of a function.

we should avoid using destructors because before GC destroys the object it first executes destructor in that case it will have to wait for code to release the umanaged resource. resultin in additional delays in GC. So its recommended to implement IDisposable interface and write cleaup code in Dispose method and call GC.SuppressFinalize method so instructing GC not to call your constructor.

Can we force garbage collector to run ?

System.GC.Collect() forces garbage collector to run. This is not recommended but can be used if
situations arises.

What is reflection?

All .NET assemblies have metadata information stored about the types defined in modules. This
metadata information can be accessed by mechanism called as “Reflection”.System. Reflection
can be used to browse through the metadata information.

Using reflection you can also dynamically invoke methods using System.Type.Invokemember.
Below is sample source code if needed you can also get this code from CD provided, go to
“Source code” folder in “Reflection Sample” folder.

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim Pobjtype As Type
Dim PobjObject As Object
Dim PobjButtons As New Windows.Forms.Button()
Pobjtype = PobjButtons.GetType()

For Each PobjObject In Pobjtype.GetMembers
LstDisplay.Items.Add(PobjObject.ToString())
Next
End Sub
End Class

Sample source code uses reflection to browse through “Button” class of “Windows.Forms”. If
you compile and run the program following is output as shown in “Sample Reflection Display”.
Using reflection you can also dynamically invoke a method using

“System.Type.InvokeMember”.

RELATED POST

FAQ'S ON MANIFEST

48.9

Test Automation Check points and Control Points

Control Points

In any given automation tool the overall control of AUT is by Object identification technique. By this unique feature the tool recognizes the Application as an medium to interrogate with the Tester supplied inputs and tests the mobility of the Business Logistics.

Invoking this object identification technique the test tool does have certain control features that checks the application at various given point of time. Innumerous criteria, myriads of object handlers, plenty of predefined conditions are the features that determine the so-called object based features of the Functional Check points. Each tester has a different perspective of defining the Control points.

If. … Else:

1. Before we start the “if else” construct the nature of the control point is commented along side.

For e.g.,

# Home Page Validation

If ( == “0”)

print (“Successfully Launched”);

else

print (“Operation Unsuccessful”);

2. For all Data Table operation the return-code of the Open function should be handled in the “if else” construct.

Check Points

1. Any checkpoints should not be a component of X & Y Co-ordinate dependant. In practical terms if there is a Check point that is defined on X,Y Parameters then the usability of the control point wouldn’t make any sense for the application to test. The following are some of the criteria which denotes the do’s and don’t’s of checkpoints.

S.No

Check Point

Include

Exclude

1

Text Check

Capture Text,

Position of the Text, Font & Font Size, Text area,

2

Bitmap Check

only the picture

Window or Screen that holds the picture, x-y co-ordinates,

3

Web Check

URL Check, orphan page

Avoid any text validation

1. As a case study, the WinRunner automation tool is mentioned here as examples for creating check points. Usage of OBJ_CHECK_INFO or WIN_CHECK_INFO can be avoided and inculcate the idea of creating always the GUI Check point with Multiple Property. The advantages are to identify every small object with its clause, properties and its relativity with the previous versions.

This not only enables the Regression comparisons but also it gives you the flexibility of defining the GUI Checks in all Physical state of the Object.


RELATED POST


ERROR CHECK LIST FOR INSPECTIONS

WALK THROUGHS IN TESTING

TESTING FOR SPECIALIZED ENVIRONMENTS PART ONE

TESTING FOR SPECIALIZED ENVIRONMENTS PART TWO

VALIDATION TESTING

SYSTEM TESTING


DEBUGGING AND TESTING

DEFECT AMPLIFICATION AND REMOVAL

ITERATIVE SPIRAL MODEL

STANDARD WATER MODEL

CONFIGURATION MANAGEMENT


CONTROLLED TESTING ENVIRONMENT

RISK ANALYSIS PART ONE


RISK ANALYSIS PART TWO

BACK GROUND ISSUES

SOFTWARE REVIEWS PART ONE

SOFTWARE REVIEWS PART TWO

SOFTWARE RELIABILITY

SAFETY ASPECTS

MISTAKE PROOFING

SCRIPT ENVIRONMENT

V MODEL IN TESTING

Script Environment in Software Testing

The basic idea of setting the Test Bed is that the Test Suite must be potable and can readily be ran in any environment given the initial conditions. For this to happen, the automation tool supports a lot of functions to evolve a generic methodology where we can wrap up the entire built-ins to run before the Test Suite start executing the Script. In other word the fashion of organizing the Test Scripts remain in the developer’s mind to harbinger the issues and hurdles that can be avoided with little or less of programming.

Common Functions that get into Initialization Script are

1. Usage of built-in commands to keep the test path dynamically loaded. Options to rule out the possibility of Test Path Definitions

2. Close all the object files and data files in the Initialization Script

3. Connection to the database should be done in the Inits Script

4. Always Unload and Load the Object library, and it should be done only in Inits Script.

5. Define all the “public” Variables in the Inits Script

6. Establish the db connections in the Inits Test Script

Test Scripts Elements:

Prior to the development of Test Scripts the fashion of arranging the Test Scripts needs a proper planning. Lets look at few inputs on arranging the Test ware.

Test Ware

Test Repository

Test Suite

Should contain Sub Folders, Exception Handlers, Global Object files, Set Data file, Driver Scripts, Initialization & Termination scripts

Driver Script

Object Checks, Bit Map Checks, Text Check, Web Check, User defined Functions, Global test Report Folder

Driven Script

GUI/Bit/Text Check, External Libraries, I/O Handlers

5.1

RELATED POST


ERROR CHECK LIST FOR INSPECTIONS

WALK THROUGHS IN TESTING

TESTING FOR SPECIALIZED ENVIRONMENTS PART ONE

TESTING FOR SPECIALIZED ENVIRONMENTS PART TWO

VALIDATION TESTING

SYSTEM TESTING


DEBUGGING AND TESTING

DEFECT AMPLIFICATION AND REMOVAL

ITERATIVE SPIRAL MODEL

STANDARD WATER MODEL

CONFIGURATION MANAGEMENT


CONTROLLED TESTING ENVIRONMENT

RISK ANALYSIS PART ONE


RISK ANALYSIS PART TWO

BACK GROUND ISSUES

SOFTWARE REVIEWS PART ONE

SOFTWARE REVIEWS PART TWO

SOFTWARE RELIABILITY

SAFETY ASPECTS

MISTAKE PROOFING

SCRIPT ENVIRONMENT

V MODEL IN TESTING

Dot net FAQ's on Manifest and Assemblies

What is Manifest?

Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the
following things :

√ Version of assembly

√ Security identity

√ Scope of the assembly

√ Resolve references to resources and classes.

√ The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a stand-alone PE file that contains only assembly manifest information.

Where is version information stored of an assembly ?

Version information is stored in assembly in manifest.

(I)Is versioning applicable to private assemblies?

Versioning concept is only applicable to global assembly cache (GAC) as private assembly lie in
their individual folders.

What is GAC ?

Twist :- What are situations when you register .NET assembly in GAC ?

GAC (Global Assembly Cache) is used where shared .NET assembly reside. GAC is used in the
following situations :-

√ If the application has to be shared among several application.

√ If the assembly has some special security requirements like only administrators can remove the assembly. If the assembly is private then a simple delete of assembly the assembly file will remove the assembly.

Note :- Registering .NET assembly in GAC can lead to the old problem of DLL hell, where COM version was stored in central registry. So GAC should be used when absolutely necessary.

What is the concept of strong names ?

Twist :- How do we generate strong names ?

Twist :- What is use the of SN.EXE ?

Twist :- How do we apply strong names to assembly?

Twist :- How do you sign an assembly?

Strong name is similar to GUID(It is supposed to be unique in space and time) in COM components.Strong Name is only needed when we need to deploy assembly in GAC. Strong Names helps GAC to differentiate between two versions. Strong names use public key cryptography (PKC) to ensure that no one can spoof it.PKC use public key and private key concept.



78.4
RELATED POST

FAQ'S ON MICROSOFT DOT NET ASSEMBILIES

TEST TOOL AUTOMATION BEST PRACTICES

Definition of Tests

As a prime entry point defining the test needs a idea to classify the scripts into finer elements of functions each contributing the various aspects of automation Techniques.

Looking into this perspective the elements of the automation Script would require the Record Play Back techniques, details of the application as better understood as Objects in tools, execution of Business Logic using loop constructs, and the test data accessibility for either Batch Process or any Back end operations. Ultimately we need this entire salient features to function at the right point of time getting the right inputs. To satisfy these criteria we require a lot of planning before we start automating the Test Scripts.

Test Recorder

In automation tools the Test Recorder is of two modes Object based and Action Mode. It requires a meticulous but yet a simplified approach on which mode to use. Though it is inevitable to avoid Action mode, it is still used for many at TE Based applications. As a best practice the object based is widely accepted and mandatory mode of operation in test automation. To the extent possible we will avoid Action based functions and stick on the object mode of operation.

Generic Test Environment Options

Some common Settings we need to set in General Options:

1. Default Recording Mode is Object mode

2. Synch Point time is 10 seconds as default

1. When Test Execution is in Batch Mode ensure all the options are set off so that the Batch test runs uninterrupted

2. In the Text Recognition if the Application Text is not recognizable then the Default Font Group is set. The Text Group is identified with a User Defined Name and then include in the General Option.

Test Properties

1. Every Script before recording ensure that the Test properties is in Main Test with the defaults

2. Do not entertain any Parameters for Main Test

3. It is not a good practice to load the Object library from the Test Options (if any). Rather the Object library is loaded from the Script using the suitable tool commands. This would actually avoid the hidden settings in the Script and also the ease of Setting the Object library Load and Unload can be better done dynamically in the Test Script rather than doing it manually every time the Test Suite is ran.

4. Ensure the Add-ins is correct from the Add-ins tab.

4.2

RELATED POST


ERROR CHECK LIST FOR INSPECTIONS

WALK THROUGHS IN TESTING

TESTING FOR SPECIALIZED ENVIRONMENTS PART ONE

TESTING FOR SPECIALIZED ENVIRONMENTS PART TWO

VALIDATION TESTING

SYSTEM TESTING


DEBUGGING AND TESTING

DEFECT AMPLIFICATION AND REMOVAL

ITERATIVE SPIRAL MODEL

STANDARD WATER MODEL

CONFIGURATION MANAGEMENT


CONTROLLED TESTING ENVIRONMENT

RISK ANALYSIS PART ONE


RISK ANALYSIS PART TWO

BACK GROUND ISSUES

SOFTWARE REVIEWS PART ONE

SOFTWARE REVIEWS PART TWO

SOFTWARE RELIABILITY

SAFETY ASPECTS

MISTAKE PROOFING

SCRIPT ENVIRONMENT

V MODEL IN TESTING

SOFTWARE DEVELOPMENT PROCESS PART ONE

USER REQUIREMENT SPECIFICATION :

· If the customer gives the specification, the designated team will evaluate the existing system. If the specification is found incomplete, then a study should be conducted to fill the gaps.

· Studies may be conducted at the customer site.

· Functionality of the proposed system and gaps in existing system, if any.

PROJECT INITIATION:

· PROJECT CODE

· IDENTIFY BASIC REQUIREMENTS

· IDENTIFY QUALITY OBJECTIVES

· PROJECT ESTIMATION

IDENTIFY RESOURCES REQUIRED FOR PROJECT

· HARDWARE

· SOFTWARE

TRAINING REQUIREMENT

IDENTIFY MAJOR MILESTONES

· Decide about the major milestones as per the project requirements along with possible deliverables.

EXIT CRITERIA

METRICS

· Time and effort spent in the Project Initiation activity shall be collected as per Metrics definitions

OUTPUT ITEMS

PROJECT DEFINITOIN:

INTRODUCTION

· PROJECT DEFINITION

· PURPOSE & SCOPE

SOFTWARE PROCESS

· LIFECYCLE ACTIVITIES

· ESTIMATION

· REVIEWS

· DEFECT MANAGEMENT

· CONFIGURATION MANAGEMENT & CONTROL

MANAGEMENT PROCESS

        • DEPENDENCY MANAGEMENT

  • TRACKING AND RE-PLANNING

  • RISK MANAGEMENT

  • METRIC COLLECTION

  • CHANGE MANAGEMENT

· Identify the major modules and their functionalities

· Identify the data sources, inputs to the current and proposed system.

· Identify performance, security, quality, deployment/implementation and training related requirements.

· Document customer suggestions

· Identify the development methodology

· Identify constraints and limitations relating to hardware, software or any other project related issues

· Identify method of delivery and time frames/phases requested by customer.

RELATED POST


ERROR CHECK LIST FOR INSPECTIONS

WALK THROUGHS IN TESTING

TESTING FOR SPECIALIZED ENVIRONMENTS PART ONE

TESTING FOR SPECIALIZED ENVIRONMENTS PART TWO

VALIDATION TESTING

SYSTEM TESTING


DEBUGGING AND TESTING

DEFECT AMPLIFICATION AND REMOVAL

ITERATIVE SPIRAL MODEL

STANDARD WATER MODEL

CONFIGURATION MANAGEMENT


CONTROLLED TESTING ENVIRONMENT

RISK ANALYSIS PART ONE


RISK ANALYSIS PART TWO

BACK GROUND ISSUES

SOFTWARE REVIEWS PART ONE

SOFTWARE REVIEWS PART TWO

SOFTWARE RELIABILITY

SAFETY ASPECTS

MISTAKE PROOFING

SCRIPT ENVIRONMENT

V MODEL IN TESTING

BASIC PATH TESTING WHITE BOX TESTING

Basis path testing is a white box testing technique first proposed by Tom McCabe . The basis path method enables the test case designer to derive a logical complexity measure of a procedural design and use this measure as a guide for defining a basis set of execution paths. Test cases derived to exercise the basis set are guaranteed to execute every statement in the program at least one time during testing.

Cyclomatic Complexity

Cyclomatic complexity is a software metric that provides a quantitative measure of the logical complexity of a program. When used in the context of the basis path testing method, the value computed for cyclomatic complexity defines the number of independent paths in the basis set of a program and provides us with an upper bound for the number of tests that must be conducted to ensure that all statements have been executed at least once.

An independent path is any path through the program that introduces at least one new set of processing statements or a new condition. When stated in terms of a flow.

Condition Testing

Condition testing is a test case design method that exercises the logical conditions contained in a program module. A simple condition is a Boolean variable or a relational expression, possibly preceded with one NOT (¬) operator. A relational expression takes the form

e1 E2

where E1 and E2 are arithmetic expressions and is one of the following: <, <, =, ≠ (nonequality), >, or ≥. A compound condition is composed of two or more simple conditions, Boolean operators, and parentheses. We assume that Boolean operators allowed in a compound condition include OR (|), AND (&) and NOT (¬). A condition without relational expressions is referred to as a Boolean expression.

Therefore, the possible types of elements in a condition include a Boolean operator, a Boolean variable, a pair of Boolean parentheses (surrounding a simple or compound condition), a relational operator, or an arithmetic expression.

If a condition is incorrect, then at least one component of the condition is incorrect. Therefore, types of errors in a condition include the following:

• Boolean operator error (incorrect/missing/extra Boolean operators).

• Boolean variable error.

• Boolean parenthesis error.

• Relational operator error.

• Arithmetic expression error.

The condition testing method focuses on testing each condition in the program. Condition testing strategies generally have two advantages. First, measurement of test coverage of a condition is simple. Second, the tea coverage of conditions in a program provides guidance for the generation of additional tests for the program.

The purpose of condition testing is to detect not only errors in the conditions of a program but also other errors in the program. If a test set for a program P is effective for detecting errors in the conditions contained in P, it is likely that this test set is also effective for detecting other errors in P. In addition, if a testing strategy is effective for detecting errors in a condition, then it is likely that this strategy will also be effective for detecting errors in a program.

RELATED POST



ERROR CHECK LIST FOR INSPECTIONS

WALK THROUGHS IN TESTING

TESTING FOR SPECIALIZED ENVIRONMENTS PART ONE

TESTING FOR SPECIALIZED ENVIRONMENTS PART TWO

VALIDATION TESTING

SYSTEM TESTING


DEBUGGING AND TESTING

DEFECT AMPLIFICATION AND REMOVAL

ITERATIVE SPIRAL MODEL

STANDARD WATER MODEL

CONFIGURATION MANAGEMENT


CONTROLLED TESTING ENVIRONMENT

RISK ANALYSIS PART ONE


RISK ANALYSIS PART TWO

BACK GROUND ISSUES

SOFTWARE REVIEWS PART ONE

SOFTWARE REVIEWS PART TWO

SOFTWARE RELIABILITY

SAFETY ASPECTS

MISTAKE PROOFING

SCRIPT ENVIRONMENT

V MODEL IN TESTING

Strings in Java

v

g: S

String is Immutable and String Is a final class. The String class provides for strings whose value will not change.

One accessor method that you can use with both strings and string buffers is the length() method, which returns the number of characters contained in the string or the string buffer. The methods in String Class:-

toString( ) equals( ) indexOff( ) LowerCase( )

charAt( ) compareTo( ) lastIndexOff( ) UpperCase( )

getChars( ) subString( ) trim( )

getBytes( ) concat( ) valueOf( )

toCharArray( ) replace( )

ValueOf( ) : converts data from its internal formate into human readable formate.

toString() : An instance method that converts the object to a string.

charValue() :An instance method that returns the value held by the character object as a primitive char value.

isUpperCase(char) : A class method that determines whether a primitive char value is uppercase.

RELATED POST

INITIALIZATION IN JAVA

Assignments and Initializations in Java

Initialization in Java:

After you declare a variable, you must explicitly initialize it by means of an assignment statement—you can never use the values of uninitialized variables. You assign to a previously declared variable using the variable name on the left, an equal sign (=), and then some Java expression that has an appropriate value on the right.


int vacationDays; // this is a declaration

vacationDays = 12; // this is an assignment

Here's an example of an assignment to a character variable:
char yesChar;

yesChar = 'Y';

One nice feature of Java is the ability to both declare and initialize a variable on the same line.
For example:

int vacationDays = 12; // this is an initialization

Finally, in Java you can put declarations anywhere in your code. For example, the following is valid code in Java:

double salary = 65000.0;

System.out.println(salary);

int vacationDays = 12; // ok to declare variable here

you cannot declare two variables with the same name in the same scope.

Constants:

In Java, you use the keyword final to denote a constant. For example,
public class Constants
{
public static void main(String[] args)
{
final double CM_PER_INCH = 2.54;
double paperWidth = 8.5;
double paperHeight = 11;
System.out.println("Paper size in centimeter: "
paperWidth * CM_PER_INCH + " by "
paperHeight * CM_PER_INCH);
}
}
The keyword final indicates that you can assign to the variable once, then its value is set once and for all. It is customary to name constants in all upper case. It is probably more common in Java to want a constant that is available to multiple methods inside a single class. These are usually called class constants. You set up a class constant withthe keywords static final. Here is an example of using a class constant:

public class Constants2
{
public static final double CM_PER_INCH = 2.54;;
public static void main(String[] args)
{
double paperWidth = 8.5;

double paperHeight = 11;

System.out.println("Paper size in centimeter: "
+ paperWidth * CM_PER_INCH + " by "
+ paperHeight * CM_PER_INCH);
}
}


Note that the definition of the class constant appears outside the main method. Thus, the constant can also be used in other methods of the same class. Furthermore, if the constant is Declared public, methods of other classes can also use the constant.

const is a reserved Java keyword, but it is not currently used for
anything. You must use final for a constant.

RELATED POST

JAVA PROGRAMMING ENVIRONMENT