JUnit is a unit testing framework for the Java programming language. Created by Kent Beck and Erich Gamma, JUnit is one of, and arguably the most successful of, the xUnit family of frameworks that originated with Kent Beck's SUnit. JUnit has spawned its own ecosystem of JUnit extensions. Experience gained with JUnit has been important in the development of test-driven development, and as a result, some knowledge of JUnit is often presumed in discussions of test-driven development, for example in the book Test-Driven Development: By Example, ISBN 0-321-14653-0 by Kent Beck. JUnit has been ported to other languages, including C# (NUnit), Python (PyUnit), Fortran (fUnit), and [[C++]] (CPPUnit). This family of unit testing frameworks is referred to collectively as xUnit. TestNG has many of the same goals as JUnit. And more recently, owing to the development of rich client frameworks such as AJAX, a port of JUnit has been developed for JavaScript (JSUnit) http://www.jsunit.net/. "Hello world" example in JUnit 3.8 and earlier: public class HelloWorld extends TestCase { public void testMultiplication() { // Testing if 2*2=4: assertEquals ("Multiplication", 4, 2*2); } } (compare with the similar example for Mauve.) The method testMultiplication will be discovered automatically by reflection. "Hello world" example in JUnit 4.0: public class HelloWorld { @Test public void testMultiplication() { // Testing if 2*2=4: assertEquals ("Multiplication", 4, 2*2); } } JUnit is a unit tester for Java. Its used for running tests while programming in Java
All programming languages need to be converted to machine code. Machine code is the native language of the machine; it is the only language understood by the machine. When we write programs in other languages they must be translated into machine code. To achieve that, we need to write a program to perform the translation for us.
For this we can either use an assembler, a compiler or an interpreter, all of which are machine code programs. Assemblers can only be used with assembly languages, which are low-level symbolic languages that translate near 1:1 with the machine code. The machine code can be saved and executed without further translation. However, assembly languages are not portable; each machine architecture has its own specific version of machine code and therefore requires its own specific assemblers to produce it. To port the code to another architecture you essentially have to re-write the entire source code. There are tools (pre-processors) that can help make the task easier but it's by no means a straightforward process.
[The reverse of assembling is disassembling, which converts machine code into a low-level language that is similar to assembly but is known as disassembly. However, since an assembler strips out all variable names and user comments, a disassembler cannot restore the original assembly language code. Indeed it is impossible to restore the original source code no matter what language was used. Disassembly is as good as it gets.]
All high-level languages are either compiled or interpreted or are both compiled and interpreted.
Compiled languages compile the entire source code into machine code, much like assembly language but with a higher level of abstraction between the source and the machine code. As with assembly languages, the machine code can be saved and executed without any further translation. Being more abstract, compiled languages are much easier to port to other architectures than assembly languages. However they must still be compiled separately upon each architecture. The most popular examples of compiled languages are C and C++.
Interpreted languages do not translate the entire source code, they step through the source code one statement at a time, converting each statement to machine code and executing it before moving onto the next statement. This has the advantage over compiled languages in that you do not have to wait for the entire program to compile before executing the program. A compiled language program can take several minutes to compile, whereas an interpreted language can be executed immediately. However, the need to interpret every statement before executing it incurs a performance penalty. With compiled languages, you only pay the cost during compilation; once compiled, you do not need the compiler. Interpreted languages cannot execute without the interpreter, but any machine that has a suitable interpreter can execute the same source code regardless of which machine architecture it was written on. The most popular interpreted language is BASIC since it is the language most programmers learn before moving onto other languages.
Languages that are both compiled and interpreted use a compiler to produce an intermediate source known as byte code. Byte code is not machine code, it still has to be interpreted, however the byte code "statements" are much simpler to interpret than an interpreted language's statements thus it performs much better. Also, unlike compiled languages, the compiled byte code is highly portable. The best example of such a language is Java which compiles to Java byte code suitable for interpretation by the Java virtual machine (JVM). Given that virtually all platforms provide a JVM implementation, it's no surprise that Java is by far the most popular application programming language in use today. However, it's lack of low-level features limits its usefulness in non-application fields such as driver software, operating system kernels and embedded systems software. Its performance and memory consumption also leaves a lot to be desired, however it's ease-of-use makes it a good stepping stone to learning C++.
What is the valid range of numbers for int type of data?
The valid range of numbers for int is 32768 to 32767.
What are the difference between roster method and rule method?
what is the difference between roster method and rule method
Can you declare an instance variable of class StringBuffer in Java program?
Here's how to create a StringBuffer instance.
StringBuffer sb = new StringBuffer();
sb.append("Add this is to the buffer");
// ...
Note the StringBuffer has synchronized methods so if it is only accessed in a single thread context then a StringBuilder is preferred. StringBuffer and StringBuilder both implement the Appendable and CharSequence interfaces so can be used interchangeably.
Can a passenger jet do a loop the loop?
legally no - safely and ethically no - technically most large passenger jets no though a few might if done very carefully with minimal fuel and no passengers (in otherwords as lightly loaded as possible)
planes are certified for certain flying conditions based on the forces they are designed to withstand - the stronger a plane is built the heavier it has to be - the heavier it is the less payload (cargo and passengers) it can carry - passenger jets need to carry as much payload as possible so are built as light as safety permits which means no sudden or severe forces are allowed or damage will result (such as the Chicago ohare crash quite awhile back where the copilot made several sudden rudder movements that caused the tail section to break off)
a loop requires a fast speed when first entering since the speed drops rapidly as altitude is gained - otherwise the vertical altitude gain would have to be done entirely by the engines and as powerful as the big jet engines are they don't even have the power to hold it still let alone push it up like a rocket - problem is the heavy jets need to be doing a very fast speed, at least 400 to 600 mph to start the loop to have enough speed to finish it - which means any sudden change in vetical speed puts a huge force on the already very heavy wings - going up at a steep rate of climb for a loop at say 500 mph will rip the wings off almost any heavy jet
next problem is descending from the top of the loop where the weight of the plane can cause it to overspeed since the heavies don't have airbrakes and you cant reverse thrust at those conditions without ripping them apart and flaps are too weak for those forces to use as breaks - when a plane reaches its maximum speed it startes vibrating/shaking and would eventually shake itself apart
all this said it may be possible for some of the smaller jets (737 etc) under controlled conditions and a bit of planning to be able to loop - i don't know if its ever been tried but it may be possible - but then the plane would probably not be airwothy anymore due to the stresses it undergoes so its not likely any one will try it with a multimillion dollar commercial aircraft - wonder if anyone wants to risk their personal 737?!
Barrel RollA barrel roll is when the planes flies on one heading and rolls over upside down as if the a/c is rolling inside a barrel. Test Pilot "Tex" Johnson barrel rolled a Boeing 707 airliner.Link to a video of this event:
http://www.youtube.com/watch?v=Ra_khhzuFlE
During the hi-jacking of a FedEx cargo DC10-30, the flight crew rolled the a/c almost inverted in order to throw the hi-jacker off his feet, while he was fighting one of the crewmembers.
Reference "Hijacked" by Dave Hirschman
Answer #3
Probably at least some of them could. It might not be a classic, circular loop, but with the right entry speed and enough altitude it probably could be done. Of course you'd have to find someone willing to risk a $40M+ airplane (in the case of a 737; more for larger airplanes) on a rather stupid stunt, and also a pilot willing to fly it.
Of course, the airplane manufacturer would probably have a fit over the liability issues . . .
Airshow pilot Bob Hoover used to do such stunts with Aero Commander 500s and Sabreliners; it should be possible with even larger airplanes. YouTube has a video of Bob Hoover looping his unmodified, straight-stock Commander 500--with the engines shut down:
http://www.youtube.com/watch?v=9ZBcapxGHjE
During his routines he never exceeded 2Gs on the airplane, which is well within the certification limits of all transport-category airplanes. Looping an airliner should be possible without damaging the airplane. It's just the thought of what might happen that's kept anyone from actually trying it.
When might you want the compiler to ignore type differences in an expression?
a compiler cannot "ignore" type differences, it only can silently
"convert" the items into a common data type, before further
processing. Such conversions require rules, how to make different
types compatible
What are the advantage of oops language?
Advantages of OOP Object-Oriented Programming has the following advantages over conventional approaches: * OOP provides a clear modular structure for programs which makes it good for defining abstract datatypes where implementation details are hidden and the unit has a clearly defined interface. * OOP makes it easy to maintain and modify existing code as new objects can be created with small differences to existing ones. * OOP provides a good framework for code libraries where supplied software components can be easily adapted and modified by the programmer. This is particularly useful for developing graphical user interfaces. Concepts of OOP: * Objects * Classes * Data Abstraction and Encapsulation * Inheritance * Polymorphism Objects Objects are the basic run-time entities in an object-oriented system. Programming problem is analyzed in terms of objects and nature of communication between them. When a program is executed, objects interact with each other by sending messages. Different objects can also interact with each other without knowing the details of their data or code. Classes A class is a collection of objects of similar type. Once a class is defined, any number of objects can be created which belong to that class. Data Abstraction and Encapsulation Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes. Storing data and functions in a single unit (class) is encapsulation. Data cannot be accessible to the outside world and only those functions which are stored in the class can access it. Inheritance Inheritance is the process by which objects can acquire the properties of objects of other class. In OOP, inheritance provides reusability, like, adding additional features to an existing class without modifying it. This is achieved by deriving a new class from the existing one. The new class will have combined features of both the classes. Polymorphism Polymorphism means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends on the data types used in the operation. Polymorphism is extensively used in implementing Inheritance.
Why you cannot have full control over computer hardware when programming in high level language?
The higher level languages simplify instructions that could have taken many steps in a low level language. So puts("hello"); could be 20 instructions in assembler. So through this simplification, you lose a degree of control, depending on how high the language is.
In computer terminology, the thread refers to the sequence of instructions that have been executed. When the computer reaches a decision point (if x > 1), the thread may take either of two paths.
An "exception" simply means that something happened that was not expected or something that resulted in an unpredictable outcome.
Effectively, a thread exception means that the computer ended up in an unexpected section of code. Thread exceptions can often be the result of pointer errors.
default
Differences between XA and Non XA Data sources?
An XA transaction, in the most general terms, is a "global transaction" that may span multiple resources. A non-XA transaction always involves just one resource.
An XA transaction involves a coordinating transaction manager, with one or more databases (or other resources, like JMS) all involved in a single global transaction. Non-XA transactions have no transaction coordinator, and a single resource is doing all its transaction work itself (this is sometimes called local transactions).
XA transactions come from the X/Open group specification on distributed, global transactions. JTA includes the X/Open XA spec, in modified form.
Most stuff in the world is non-XA - a Servlet or EJB or plain old JDBC in a Java application talking to a single database. XA gets involved when you want to work with multiple resources - 2 or more databases, a database and a JMS connection, all of those plus maybe a JCA resource - all in a single transaction. In this scenario, you'll have an app server like Websphere or Weblogic or JBoss acting as the Transaction Manager, and your various resources (Oracle, Sybase, IBM MQ JMS, SAP, whatever) acting as transaction resources. Your code can then update/delete/publish/whatever across the many resources. When you say "commit", the results are commited across all of the resources. When you say "rollback", _everything_ is rolled back across all resources.
The Transaction Manager coordinates all of this through a protocol called Two Phase Commit (2PC). This protocol also has to be supported by the individual resources.
In terms of datasources, an XA datasource is a data source that can participate in an XA global transaction. A non-XA datasource generally can't participate in a global transaction (sort of - some people implement what's called a "last participant" optimization that can let you do this for exactly one non-XA item).
How do you encrypt a string in java by replacing the characters with the next alphabet?
A "for" loop, looping through each character, should work just fine. Just get one character at a time, add one to it, and add it to the end of the new string. Using a String object for the new string should work, but it is inefficient for large strings; in this case, a StringBuffer provides better performance. By the way, it should be noted that this is not a very secure encryption.
Difference between symbian and java phone?
both are mobile operating syms but sybm is more faster than the java
How do you search for a string in a file in VB?
This is a simple function which will read the file line by line and search each individual line until the target string is found, then return the line number it was found in. It will return zero if the string was not found.
This is a simple function whipped up to demonstrate the basic technique, it has not been debugged or tested at all, and is certainly not the best solution possible. It also lacks any form of error trapping/handling.
You should not use this code in any program intended for production without rewriting it.
public function FindStringInFile(byval strTarget as string) as long
Dim iFile as integer 'file number
Dim iLineNum as long 'counter for line number
Dim strTmp as string 'variable length string to hold string from file
Dim bFound as boolean 'flag to indicate it was found
'First, open the file for input:
iFile = freefile 'get the next free file number
open "filename.txt" for input as #iFile 'open the file in input mode
do until eof(ifile) 'continue reading lines until the end of the file
line input #ifile, strTmp 'read a line into the string variable iLineNum = iLineNum + 1 'increment the line number counter
if instr$(strTarget, strTmp) <> 0 then 'set the flag and exit the loop
bFound = true
exit do
end if
loop
'check the flag
if bFound then
'found, return the line number
FindStringInFile = iLineNum
else
'not found, return zero
FindStringInFile = 0
end if
end function
Do you need java for my browser to work?
In general, not. The browser will work without Java; some individual sites that require Java will NOT work.
Write a program in c to display isosceles triangle dy digit?
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("\n Enter the 3 sides of Triangle: ");
scanf("%d %d %d",&a,&b,&c);
printf("\nYour entered side is a=%d b=%d c=%d",a,b,c);
if(a==b && b==c && a==c)
{
printf("\n EQUILATERAL TRIANGLE.");//All sides equal in case of Equilateral triangle
}
else if(a!=b&&b!=c)
printf("\n SCALENE TRIANGLE."); //All sides unequal
else
printf("\n ISOCELES TRIANGLE."); //At least 2 sides equal
getch();
}
The is a unique character string used to identify an access point?
it's called the SSID (service set identifier)
Java byte code.
Do the primitive datatypes in java have objects?
No Primitive data types do not have objects.
As of Java 1.5, all primitive types in Java have "wrapper" classes. These classes serve two purposes:
# They keep all type-specific methods together in one place. # They allow primitive types to be used in situations which take advantage of generics (also introduced in Java 1.5).
How oop is used for real world problems?
oop is a concept which is based on the objects and objects are the real world entities tht describe the real world problems.oop emphasises more on data abstraction and security and gives more importanceto the user requirement.as the data in oop is more secured than pop languages......oop describes the real world problems more specifically and in an efficient manner.
Write a program that prints the letter X composed of asterisks?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void draw_x(int width, int height);
int main(int argc, char *argv[]){
int width, height;
if(argc != 3){
printf("Syntax: this_program width height\n");
exit(1);
}
width = atoi(argv[1]);
height = atoi(argv[2]);
// make sure they're both positive non-zeros
if(height > 0 && width > 0){
draw_x(width, height);
}else{
printf("numbers must be naturals\n");
exit(1);
}
return 0;
}
void draw_x(int width, int height){
int tally = 0;
int drawx, drawy;
char grid[height][width + 1];
memset(grid, ' ', height * (width + 1) * sizeof(char));
if(width > height){
drawy = 0;
for(drawx = 0; drawx < width; drawx++){
tally += height;
if(tally > width){
tally -= width;
drawy++;
}
grid[drawy][drawx] = '*';
grid[drawy][width - drawx - 1] = '*';
}
}else{
drawx = 0;
for(drawy = 0; drawy < height; drawy++){
tally += width;
if(tally > height){
tally -= height;
drawx++;
}
grid[drawy][drawx] = '*';
grid[drawy][width - drawx - 1] = '*';
}
}
for(drawy = 0; drawy < height; drawy++){
grid[drawy][width] = 0;
printf("%s\n", grid[drawy]);
}
}
What can you do with a buisiness domain?
If one is inquiring about a business domain name then those are simply used to run an e-commerce business. A business domain may also refer to programming concepts in object oriented programming languages.
How do you compile java files into class files using eclipse?
Alright, just answered my own question. The steps, are a bit, complicated, so stick with me.
1) Open up eclipse, and click File>New>Project
2) In the window, select the 'Java Project' option under the 'java' folder
3) Give the project a name. Keep in mind that this will be a folder name, not a file name. I recommend for starters to name the folder "Java Test"
4) Uncheck the box that says Use Default Location, and change the location given to the location of the folder you will files in.*
5)Click Finish. You now have a new project.
6) Click File>New>Untitled Text Document
7) Make your program. (If you need a simple file, google hello world java)
8) Click File>Save as and save it as a .java file. This means give it a name, and slap a .java on the end
9) Click Project>Clean and check the project whose files you want compiled
10) Click OK
11) The changes will not show up in eclipse, but open up the folder outside of java, and you will see the compiled class files