How do you run java source code on a website?
http://powderurmonkey.com/forums/showthread.php?p=3#post3
What are the sum of the first 100 integers using the do while loop and display the result?
public class TestBB {
/**
* @param args
*/
public static void main(String[] args) {
int sum = 0;
int i = 0;
do {
sum = sum + i;
i++;
} while (i <= 100);
System.out.println("Total of 100 numbers is: " + sum);
}
}
What is wrapper class and its use?
When we need to store primitive datatypes(The data types we use in genera like:int,long,float etc)as objects, we use
wrapper classes.Means in utility classes all the utility
classes stores Objects.So when we need to store a primitive
datatype,We make an object of that primitive data and store it.
Say supposing there is a requirement to store only the
object in an array A.The Primitive types cannot be stored in
the same array as the array can accommodate only Objects
here is where Wrapper Class come into picture.ie, we create
wrapper for the primitive types.One such example is as below
Ex:int i;
Wrapper class for the primitive type(int) is created as below:
Integer i = new Integer();
That's why we use Wrapper classes in Java
What is mean by selection sort?
Selection sort works by looking for the largest value in a set and swapping it with the last value. The last value can now be ignored since it is now in place. The process repeats with the remainder of the set. After repeated passes, the remainder of the set will have only one item, the smallest value, at which point all the values will be in sorted order.
The algorithm is similar to that of bubblesort, but is generally more efficient because there can only be one swap at most for each iteration of the algorithm. With bubble sort, there may be multiple swaps per iteration. However, while the number of comparisons is the same for both algorithms, bubblesort can be optimised to minimise the number of iterations required and thus minimise the number of comparisons. Nevertheless, swapping is a more expensive operation than comparing, thus selection sort is generally faster.
Neither algorithm is suitable for sorting large sets of data.
Write a java program to print the last digit in Fibonacci series?
Just generate the Fibonacci numbers one by one, and print each number's last digit ie number%10.
What is method overloading and constructor overloading explain with?
method overriding :method overriding means redefine methods in sub classes they already defined in the Super classes.
method overloading : It means methods with the same name but with a different signature exist in one class
What is single stroking methods?
Single stroking methods refer to a technique in various fields, particularly in art and design, where a single, continuous line or stroke is used to create an image or representation. This approach emphasizes simplicity and fluidity, often producing a minimalist aesthetic. It's commonly employed in drawing, calligraphy, and graphic design, allowing for a clear and direct expression of creativity. The technique can also be applied in other areas, such as manufacturing or programming, where efficiency and precision are key.
What is explicit copy constructor?
An explicit constructor is one that is declared explicit and thus prevents implicit construction of an object. To understand explicit construction you must first understand implicit construction.
Consider the following code that uses a simple class, Square, to compute the square of any given integer:
#include
using namespace std;
class Square
{
private:
int m_number;
public:
Square(int number):m_number(number*number){}
friend void display(Square square);
};
void display(Square square)
{
cout << "Number = " << square.m_number << endl;
}
int main()
{
Square ten(10); // Explicit construction
Square twenty=20; // Implicit construction
display(ten);
display(twenty);
display(30); // What does this mean?
return(0);
}
Output:
Number = 100
Number = 400
Number = 900
Although there's nothing intrinsically wrong with the line display(30), it's not exactly clear to the reader what this line does. The display() function clearly expects an instance of a Square object, yet we're passing a literal constant.
The clue is the implicit constructor call, Square twenty = 20. Although we declared no assignment operator that accepts a literal constant, the statement implies we call the constructor, Square(int). In other words, the line is equivalent to explicitly calling Square twenty(20).
This is really no different to the way primitives work. That is, int x=5 is the same as calling int x(5), but the former is a more natural form of assignment. However, this behaviour is not always desirable. While Square twenty=5 may be fine, the unwanted side effect is that it also allows us to make ambiguous calls, like display(30).
Although the line display(30) forces the display()function to construct a local Square object using implicit construction, it's not obvious to the reader that an object is created (and subsequently destroyed), and as a result of this it isn't obvious to the reader why display(30) would produce the result Number = 900.
Note that while this usage may well be obvious to the developer while writing the code, when the developer revisits the code later, it may not be quite so obvious. And if the developer has trouble reading their own code, you can imagine how difficult it would be for a third party to understand the same code.
To avoid this problem, we must declare the constructor to be explicit:
explicit Square( int number ):m_number(number*number){}
As soon as we do this, the lines Square twenty = 20 and display(30) become invalid. To rectify this, we must replace them with calls to the explicit constructor instead:
int main()
{
Square ten(10); // Explicit constructor
Square twenty(20); // Explicit constructor
display(ten);
display(twenty);
display(Square(30)); // Explicit constructor
return(0);
}
Now it is much clearer to the reader what's going on. Although we've lost the ability to implicitly construct a Squareobject, we've assured our code remains readable at all times by enlisting the help of the compiler to ensure that we never unintentionally construct a Square object via implication.
What is the Difference between public static void and static public void?
There is no difference between public static void and static public void
How to write a code for a program that uses inheritance?
Multiple Interfaces are usually associated with name ambiguity and this is the reason that they haven't been implemented in .NET. However in order to incorporate the advantages of multiple inheritance keeping aside the issues involved, .NET has come up with one more concept known as INTERFACE.
Interfaces allow a class to inheirt behavioral characteristics frm more than one object type called interfaces. Classes implement the interfaces. You can check out the associated links for a number of examples demonstrating above concept.
Java programming to check a digit number is palindrome or not?
import java.io.*;
public class chuva
{
public static void main(String[] args) throws Exception
{
BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
int rem, quo, rev=0;
System.out.println("Enter a number: ");
int a = Integer.parseInt(x.readLine());
int b=a;
for(int ctr=0; ctr<=a; ctr++)
{
rem = a%10;
a = a/10;
rev = rev*10 +rem;
ctr=0;
}
System.out.println(+rev);
if(b==rev)
System.out.println("Palindrome");
else
System.out.println("Not Palindrome");
}
}
What is the difference between arrayList and vector in java?
1)Synchronization: Vector is synchronized and arraylist are not. 2)Increment size: Vector can increment the size by double,arraylist can increment it by 50%.
2)The default size of vector has 10, arraylist have 0.
3)we can specify the increment size with the vector and with arraylist we can't.
4)Arraylist is very fast as it is non-synchronized.
How do you write even odd program in for loop in java script?
You can use the symbol % to see the remainder of the division problem. eg. document.write(11 % 3 + "") will display the number 2 since 3 goes into 11 three times with a remainder of 2.
So here's some sample code:
function oddEven(num){
if(num % 2 == 0){
return "even"
}
else{
return "odd"
}
}
What is the difference between a programming language and an Application Programming Interface?
By what I think you asked yes but I can't give you a definite answer because your question does not make sense.
By what I can gather I think you accidently put that is after language.
Application-oriented languages are specialized languages which may be specified and implemented based on general-purpose languages and their implementations. The model used to introduce the specialized languages is based on translation. A simple model supports modifications and extensions of the general language only. An alternative model has an initial phase for defining a semantic basis for the specialized language in the form of a set of abstractions to model the concepts and notions of the application area. The use of specialized languages can be seen as an abstraction process, where several levels of languages (or language parts) are defined.
Write a program In java using while loop to reverse the digits of the number?
int n; // the number you want to reverse
int rev_n = 0;
while (n > 0) {
// shift rev_n digits left
rev_n *= 10;
// put rightmost digit of n onto right of rev_n
rev_n += n % 10;
// remove rightmost digit of n
n /= 10;
}
Feel free to edit and improve this answer; I needed an answer myself, and found the question but no answer to date, and so am giving it a whirl:
When I hear "Java" I'm thinking of a JRE or Java Runtime Environment. (It's not the same as JavaScript, however, which our present question does not touch.) JRE supports (a) the writing of applications to run on several Operating Systems; and (b) applications that need Java in order to run. So, if you don't have Java, but need either or both to write or use applications that are supported by Java, why then it seems you'd need to install Java. On the other hand, if you already have Java, and are not sure whether to uninstall it, you will want to find out whether you need to write or use such applications. The first should be easy: just ask yourself if you need to write such programs The second... here's where I'd love some help editing the answer!
Temporarily and tentatively, you could (a) right click each application you suspect might use Java, choose "properties", and see when the program was last used. Some kinds of programs that use Java are those that show 3-D images from various angles, those that move images around a lot. Example, architectural design programs, and many games. (b) Perhaps also, you can poke around in the Java files, and see if you can find out when Java was last used. In any case, you can (a) set a "Recovery Point" (in Windows at least), and then use "Add/Delete Programs" to uninstall your Java program(s), and see if everything you usually use is still working. If not, you undo the change by restoring that Recovery Point. (I'm supposing you are at least moderately computer savvy and know what you're doing, or have a friend who is.)
Part of the decision depends on the benefits and drawbacks of having Java. Its benefits are many (see the web-site of the Java folks). Its drawbacks are its huge size and consequent use of much memory and much time for installing and for updating. (It was the huge updates that got me to find and ask the same Question we're editing now.)
Usually one element at a time. If you want to process all elements of an array, you write a loop.
Usually one element at a time. If you want to process all elements of an array, you write a loop.
Usually one element at a time. If you want to process all elements of an array, you write a loop.
Usually one element at a time. If you want to process all elements of an array, you write a loop.
What does the keyword extends mean in BlueJ?
The "extends" keyword in Java is how you declare a subclass.
class Base {
void foo() {}
}
class Sub extends Base { //Sub is now a subclass of Base
void begin()
{
Sub s = new Base(); //cannot do this the other way around!
}
}
What is the different between loop and do while loop?
no difference in logic in both of them you put the key to enter :while( ....),for(;....;)
but infor loop you have option to initialize value and make operation on it
for(int i=0;...;i++){} same int i=0; while(..){ i++;}
It works on this one.
System ConfigurationSome operating systems and configurations may have trouble running Java. It is unlikely if your system and software are up to date. There was some rumors and I'm not sure how credible they are that Microsoft campained to keep Java off their older operating systems.
Not Installed?Also the more obvious solution may be that you do not have Java installed.
Check out this website to download the latest version of Java for your platform.
How would you write a program to display even numbers between 0-20?
ALGORITHM EVEN
BEGIN
FOR ( num = 0; num <= 20; num++ )
BEGIN
IF ( num MOD 2 == 0 ) THEN
DISPLAY (num)
END IF
END FOR
END EVEN
in C:
#include <stdio.h>
int main (void) { puts ("0 2 4 6 8 10 12 14 16 18 20"); return 0; }
What are the basic types of link list in java?
linear
circular
double linked linear
double linked circular
Knowing the names does not help much when your teacher will require you to actually know what the names mean. Start reading. Programming requires lots of reading.
Name the four methods a psychologist uses to gather data?
a correlational strategy naturalistic obsevation the survey technique Gallup poll.
Is java a stand alone program or not?
A standalone application is one that can be executed independently and would execute and produce some output either as a UI or on the JVM console. Any java class with a main method can be considered a mini standalone java application.
Java is a programming language. Java is an easy transition for C++ coders. C++ and Java are similar in coding styles of notation. The reason why Java is used often is because Java is safe, portable, and is being improved day by day. Java was initiated by James Gosling, Mike Sheridan, and Patrick Naughton in 1991. The mascot for Java is Duke.Java was originally designed for interactive television, but it was too advanced. Sun Microsystems (Original owner of Java) first published the first public implementation as Java 1.0 in 1995. For all new Java programmers, use the Java API as a tool for coding. Java API helps a lot on figuring out on how methods work. Unfortunately, Oracle Corporation's had an acquisition of Sun Microsystems and bought Java off them.
I underlined the important things to remember and if I have any mistakes on there can anyone please message me about this. I would like some feedback.