WAP in java to take alphabet and print ascii value for it?
Remember that chars in Java are just a special version of ints. Cast the char as an int and you get the Unicode value for it. Fortunately, the group of characters including letters and numbers have the same value in both encoding systems.
for (char letter = 'a'; letter <= 'z'; ++letter) {
System.out.println("ASCII of " + letter + " = " + (int) letter);
}
I had the same problem and managed to resolve it. You may try this too.
"Completely" cleaned up all the existing java installs: Brought up windows in safe mode, and deleted C:\Program files\Java\jre1.6 folder. Restarted in normal mode. Used "Windows Install Cleanup" and removed the Java Runtime installation. This removed the listing under Add/Remove software but the icon in control panel stayed. Then used CCleaner to clear out all the unwanted file and also to cleanout unwanted registry entries. There were plenty of entries that had to be cleaned. However, I still had to manually remove \\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft (You may rename if you want to be cautious).
After this I restarted the machine (this is important) and reinstalled JRE6U16 from the offline installation package that I had downloaded earlier.
The installation went without a hitch and now everything is fine. The Java control panel is also behaved as expected.
Hope this helps.
Why is Java not 100 percent platform independent?
Answer
Java is platform independent while JVM is platform dependent. In Java ,you can compile code in to class file and you can run it in any OS without altering your code.But for interpreting class to bytes we need JVM .so it act as a bridge between your class file and OS. Now a days JVM is available for all OS.So Java attains platform independent.
Answer
Depending on your definitions, no language may be truly platform independent. A language like Java needs a virtual machine to run the platform independent bytecode. But this virtual machine must run natively on a given physical machine, which means that the JVM in platform dependent. If someone tells you that Java is not completely platform independent, this is probably what they are referring to.
How do you compile the simple calculator in java?
Here is a calculator program I had to make in my Computer class in bluej (free java compiler)
import java.io.*;
import java.util.*;
public class Calculator
{
public static void main(String args[])
{
System.out.println("Make your arithmetic selection from the choices below:\n");
System.out.println(" 1. Addition");
System.out.println(" 2. Subtraction");
System.out.println(" 3. Multiplication");
System.out.println(" 4. Division\n");
System.out.print(" Your choice? ");
Scanner kbReader = new Scanner(System.in);
int choice = kbReader.nextInt();
if((choice<=4) && (choice>0))
{
System.out.print("\nEnter first operand. ");
double op1 = kbReader.nextDouble();
System.out.print("\nEnter second operand.");
double op2 = kbReader.nextDouble();
System.out.println("");
switch (choice)
{
case 1: //addition
System.out.println(op1 + " plus " + op2 + " = " + (op1 + op2) );
break;
case 2: //subtraction
System.out.println(op1 + " minus " + op2 + " = " + (op1 - op2) );
break;
case 3: //multiplication
System.out.println(op1 + " times " + op2 + " = " + (op1 * op2) );
break;
case 4: //division
System.out.println(op1 + " divided by " + op2 + " = " + (op1 / op2) );
}
}
else
{
System.out.println("Please enter a 1, 2, 3, or 4.");
}
}
}
How do you write a Program on garbage collector in java?
Garbage collection is an operation that happens automatically in Java. We cannot write programs to perform them. All we can do is call the system's implementation of the Garbage collector and hope that it would execute.
"Runtime.gc();"
Place the above piece of code in your code, if you want to invoke the garbage collector. Invoking the runtime's implementation of the gc does not guarantee the execution of the garbage collector. It may or may not run. The JVM decides on that.
What is the difference between sequential allocation and linked allocation in java?
Sequential allocation refers specifically to arrays. An array is, by definition, a contiguous block of memory. The index of the array is used as an offset from the memory address of the beginning of the array - this is why access to any element in an array takes a constant amount of time to compute.
"Linked allocation" is best described by linked lists. These data structures are connected by a series of nodes. A node contains at least two pieces of information: some piece of data and a reference (link) to the next node in the chain. Since changing the position of a node in a linked list only requires changing references to other nodes, insertion and deletion is trivial. Note that these "referential" linked data structures are not the only way to link data, just the easiest to understand and implement.
A remote data object is one that would be located on a different "node". For instance, a node the hardware where the operating system resides, which houses a database. Nodes have IP addresses and names. Say that the main database resided on node "Payroll" (10.128.132.10). Via a database link, an object from another node "Accounting" (10.128.142.11) is referenced. An example of this could be a view which pulls data from a table in the Payroll database and joins it to a table in the Accounting database and the view shows data from both nodes.
What is the abbrevations for int?
"int" is the abbreviation for an integer data type. In Java an int is specifically a 32-bit signed integer.
Can you use two or more run methods for a single thread in same method?
No. Each thread can have only one run method. You can overload the run method because it is just another java method but only the default run method with void return type will get called when you start the thread
What is difference between serial interface and Ethernet interface?
The FastEthernet interface of R1 is disabled.
One of the default routes is configured incorrectly.
A routing protocol is not configured on both routers.
The default gateway has not been configured on both routers.
How do you write a java program that converts kilograms to pounds?
/*POUNDS TO KILOGRAMS FORMULA
* Divide the amount in pounds by 2.2 to determine the amount in kilograms.
*
*KILOGRAMS TO POUNDS FORMULA
* Multiply the amount in pounds by 2.2 to determine the amount in pounds
*/
package poundstokilo;
import java.util.Scanner;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double pounds, kilo;
System.out.println("Enter a number in pounds");
pounds = input.nextDouble();
kilo = (pounds / 2.2);
System.out.println(pounds + " pounds is " + kilo + " kilograms");
}
What data type is the is Yes or No?
In Java, that would be called "boolean". In other languages it may have different names, for example, "logical". In C, there is no true boolean data type, so people just use integer and if you want the integer to be true, you set it to 1 and if you want it to be false, you set it to 0.
What does inherited features mean?
Java: In Java inherited features for a class are the variables and methods that are inherited from its parent class.
Ex: public class A extends B {
...
}
Here class A has access to the variables and methods in class B. This is termed as inheriting features.
General: In general, inherited features are termed as the characteristics and other aspects of a person that resemble his parents or other family members. For example a boy may have blue eyes like his mother or may have a long nose like his father etc. These are termed as inherited features.
Why is ios a virtual base class?
There is no class named "ios" anywhere in the C++ standard library. <ios> is simply the header file. The actual class is called basic_ios and this serves as the base class for the basic_istream and basic_ostream classes (declared in <istream> and <ostream> respectively).
Although most streams are used for either input or output and therefore inherit from either basic_istream or basic_ostream, some streams are used for both input and output and therefore inherit both base classes. However, because both base classes share a common base class in basic_ios, the derived stream would inherit two instances of this class where only one is required. Thus basic_istream and basic_ostream both declare basic_ios as a virtual base class, thus ensuring the most-derived object in the hierarchy inherits just one instance of basic_ios.
The enhanced for loop, new to Java 6, is a specialized for loop that simplifies looping through an array or a collection. In this chapter we're going to focus on using the enhanced for to loop through arrays. We'll revisit the enhanced for as we discuss collections in the future chapter.
Instead of having three components, the enhanced for has two.
for(declaration : expression)
The two pieces of the for statement are
• declaration The newly declared block variable, of a type compatible with the elements of the array you are accessing. This variable will be available within the for block, and its value will be the same as the current array element.
• expression This must evaluate to the array you want to loop through. This could be an array variable or a method call that returns an array. The array can be any type: primitives, objects, even arrays of arrays.
Using the above definitions, let's look at some legal and illegal enhanced for declarations:
String [] sNums = {"one", "two", "three"};
// legal 'for' declarations
for(String s : sNums) ; // loop thru the array of Strings
The enhanced for loop assumes that, barring an early exit from the loop, you'll always loop through every element of the array. The following discussions of break and continue apply to both the basic and enhanced for loops.
There are some method calls that compiler can't recognize at compile time.so it handle at run time that's called late binding.
---- by Ashok Waghmare.
What Lead to C C plus plus and java?
(C and Lisp, ... data type") was adopted by many later languages, such as ALGOL 68 (1970), Java, and C#. ... C++ has a separate Boolean data type ( 'bool' ), but with automatic conversions from ... "Report on the Algorithmic Language ALGOL 68
How do you write java program from scratch date and time class?
How everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
how everything out
What is the use of default keyword?
default is used with (switch statement) to handle what'll happen if non of the defined cases happened.
ex:
int x=4;
switch(x)
{
case 1: cout<<"1"; break;
case 2: cout<<"2"; break;
case 3: cout<<"3"; break;
default : cout<<"It's not 1 or 2 or 3 ..! ";
}
in that case .. we'll see (It's not 1 or 2 or 3 ..!)
int getNumMatches(String[] names) {
int numMatches = 0;
for(String name:names) {
if(name.endsWith("ie") name.endsWith("y")) {
++numMatches;
}
}
return numMatches;
}
How many types of user defined exceptions are there and list them?
They are user-defined. In other words: You & Me (Users) define them (make them). There is an endless number of user-defined exceptions
To check whether a string is a palindrome with using string header file?
#include
#include
void main()
{
char a[50],r[50];
int i,j;
printf("\n Enter the string:");
gets(a);
for(i=strlen(a)-1,j=0;i>=0;i--,j++)
r[j]=a[i];
r[j]='\0';
printf("\n Reverse string is %s",r);
if(strcmpi(a,r)==0)
printf("\n the original string is a pallindrome");
else
printf("\n the original string is not pallindrome");
getch();
}
Note:-If you want it case sensitive then use 'strcmp' instead of 'strcmpi'
How you can do prime number program without modules in java?