Which is more good to use for loop or while loop?
The main difference comes into picture when you use continue with them i.e. for and while.
In a while loop if continue is used before the increment of a variable is done it converts into a infinite loop.
i=1;
while(i<10)
{
/* do stuff */
if(i==6);
continue;
i++;
}
The above piece of code will turn into an infinite loop.
for(i=1;i<10;i++)
{
/* do stuff */
if(i==6);
continue;
}
In the above for loop the value of will be incremented once it attains the value 6.
Therefore it will not turn into a infinite loop.
Cheers.
astvansh> 'for' statement takes the start condition, stop condition, and the increment. 'while' statement just takes the stop condition.
One scenario (which i can think of) where while 'needs' to be used rather than a for, would be when the counter needs to be incremented/decremented conditionally...
string[] arr = {"a", "b", "b", "c"};
int i = 0;
while( i< 10)
{
// do something constructive
if(arr[i] == "b")
{
i = i + 2;
}
else
{
i++;
}
}
Cheers,
Ajeesh
Another main difference between the two: a 'for' loop is called a determinate loop, meaning that we usually use it when we know ahead of time how many iterations we want. The 'while' loop is an 'indeterminate' loop, because we usually use it in situations where we do not know the number of times the loop may iterate.
Give 5 real life example of stacks?
a) The processing of procedure calls and their terminations in computer programming. b) Arrangement of granules in chlorophylls. c) Arrangement of Plates on over another. The plate at the bottom of the plate hype is washed and kept first but, it is used or comes out last. d) Chapattis cooked first are placed at the bottom in the Tiffin and the last cooked id at the top in the Tiffin. e) Arrangement of chairs on over another. The chair which is put in first lies last when comes out.
Installation method of java games in samsung s5603?
how to install games in samsung (universal :p) 1. Create a new text document(on desktop right click > new > text document)
2. In that paste this.
<html><body><a href="_______">install _______</a></body></html>
#Write ur application/software/game name in the space provided.
for example
<html><body><a href="operamini.jar">install operamini.jar</a></body></html>
#Here operamini.jar is name of the application/software/game that is going to get installed.
#Remember that the name of the application/software/games should be same with that u write here.
#If your .JAR file name is operamini.jar then in the space provided you should type operamini.jar
3. Now rename that file to abc.html and copy both the files (''abc.html'' and the file you want to install) to a folder via Cable to the phone.
4. open abc.html in ur phone and the file you want to install is installed
Platform means the hardware and software the computer is using. It is also called "the operating system" or "OS".
What are the steps of encapsulation?
Encapsulation is the process of adding header information to the layers' data "payload". As the "payload" is passed from one TCP/IP (or OSI) layer to the next, encapsulating layer information is wrapped around the data. So, for example, if the application layer produces a data payload for transmission, it encapsulates it with application-layers headers, which then gets passed to the presentation layer. The presentation layer does the same and so down the protocol stack before transmission across the physical media. At the destination, the process is reversed by way of de-encapsulation where the headers are stripped-off by each matching layer at the destination.
1. Application, Presentation and Session layers create data. {Encapsulation headers added by layers}
2. Transport layer coverts data into segments for transport across the network. {Encapsulation headers added by layer}
3. Network layer converts segments into packets (or Datagrams). {Encapsulation headers added by layer}
4. Data Link layer converts packets (and datagrams) into Frames and the Data Link header is added. {Encapsulation headers added by layer}
5. Physical - frames are converted into bits for transmission over the physical media.{Encapsulation headers added by layer}
How do you convert a while loop to do-while loop?
A for loop is classified as an iteration statement. A simple example might be...
For x = 1 To 10
'loop body
Next x
The same loop expressed as a while loop (classified as a control flow statement) could be...
x = 0
Do While x < 11
'loop body
x = x + 1
Loop
.
Several advantages to using a modular approach in programming?
To 802.11 standard IEEE specifies what type of access method?
Network+ Guide to Networks answer: Csma/ca
In order to covert SIS files to JAR files, you will need to download a safe and virus free SIS to JAR converter. This then compresses the files and allows you to open them in JAR format.
Difference between connection - oriented and connectionless services?
Two distinct techniques are used in data communications to transfer data. Each has its own advantages and disadvantages. They are the connection-oriented method and the connectionless method:
What is markable interface in java?
The Interface which doesn't have any declarations of methods are called the markable interface (or marker interface)
They are named marker interfaces, because their only purpose is to mark special classes.
Example:
In the Java API there is the interface Cloneable. Since Object already has the method clone() the Cloneable Interface is empty and is only used to mark classes, which objects are allowed to clone.
There are Three marker interfaces that are Serializable,Remote and Cloneable.
The term ministerial exception is the law that says that the government cannot regulate the religious institutions and their hiring processes. For example, if a Christian or Catholic school has rules about not hiring homosexuals the government cannot enforce discrimination laws.
The top level class in Java is class Object. Every other class inherits from Object and therefore Object is the top most in the class hierarchy.
If you extend a class from Object such as class Animal and further extend Animal with class Dog then the hierarchy is as follows:
Object
|
Animal
|
Dog
Code for this hierachy is as follows:
class Animal {
}
class Dog extends Animal {
}
We don't need to write class Animal extends Object because every class extends from Object so it does not need to be stated.
I am pretty sure that most programming languages will work for this.
I think you're referring to the C/C++ concept of "dangling pointers." This is when you allocate some memory to a pointer, then deallocate that memory, but don't change the pointer. This causes any attempted use of the pointer to return an unused memory address.
There is no such concept in Java, since the programmer has little to no control over how memory is allocated or freed.
The closest thing I can think of is if you're using a class such as a Reader, in which you can close the object (Reader.close()) and then still have a reference to it. But in this case (and other similar cases) attempting to use the Reader further will result in an IOException being thrown.
Write a java program to find weather a given string is a palindrome or not?
import java.io.*;
class StringPalindrome
{
static void main()throws IOException
{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br= new BufferedReader(isr);
System.out.println("Enter a word");
String input=br.readLine();
int x= input.length();
char ans;
String fin="";
for(int y=x-1; y>=0; y--)
{
ans=input.charAt(y);
fin=fin+ans;
}
System.out.println("The reverse is " + fin);
if(fin.equalsIgnoreCase(input))
{
System.out.println("Palindrome");
}
else
{
System.out.println("Not a palindrome");
}
}
}
What is the similarity between abstract class and class?
They provide the same level of abstraction and encapsulation, and similar inheritance.
The differences in inheritance: an abstract class forces you to have at least 1 subclass (otherwise this abstraction branch is useless, because you won't be able to create any instance), while a non-abstract class may have optional subclasses.
Hotter than fire
Higher than Heaven
We're the Class of "2011"
2011..So nice, we're number 1 twice!
What is the similarity between an identifier and a variable?
Answer:
- identifier is the name like a, b, c, .... which is used to reference a memory location in a program. +
-
variable is the actual memory location which can hold values.
so 'a' is an identifier to a variable which is memory location located somewhere in memory.
Answer:
A Variable in Java is something that holds a particular value in a class. For example:
public class A { private String name = ""; ......
} In the above declaration name is a variable. It would hold the data of type String.
An Identifier is nothing but the name that we give for our variables, classes, methods etc. It is nothing but the name with which we identify an entity in Java. For example here A is the identifier for the class, name is the identifier for the variable etc.
What is the mathematical definition for a length of a factor string?
The number of numbers in the string; how long it is.
Why can't a c plus plus class be derived from a Java class?
I don't see why it couldn't be.
Unless the Java class uses techniques or methods which are available to Java but not C++, then there is no reason that a C++ class couldn't be based on a Java class.
What did the Anasazi's language look like?
Q. Did the Anasazi have any type of spoken language?
A. Yes! Although the Anasazi (ancestral Puebloans is another name for them) did not have a written language, they most certainly did have a spoken language. Any group of people need to be able to communicate, and the Anasazi were no different. We do know that they spoke to each other, but we cannot be sure what their language sounded like. Our best clues come from the languages of the modern Puebloan people who live in Arizona and New Mexico. You might be suprised to learn that six different languages (Tewa, Tiwa, Towa, Keres, Hopi, and Zuni) are spoken in modern Pueblo villages and that these languages come from four different language families. An example of a language family is the "Romance" family which includes Spanish, Italian, and French. These languages are descended from Latin, the language of the ancient Romans. Because so many different languages are spoken in the modern Pueblos, and because there are no written records of ancient Puebloan languages, archaeologists do not know which ancestral languages were spoken in which ancient villages in the Southwest.
(1) America evolves after the American Revolution which gained Independence from the British (1775 to 1783)
(2) Purchase of Louisiana (1804)
(3) Texas Joins The Union (1845)
(4) American Civil War (1861-1865)
(5) The Indian Wars (ran for over 200 years ending in 1890)
(6) Statehood, the creation of most of the States that exist today (28 States Created)
What are Java applets used for in programming?
Java applets are used to provide a self contained application or visually intensive experience to a user visiting a website. They are normally platform independent and as such the same Java applet can be delivered to users using Windows, Apple, or Linux.