Java Programming

The Java programming language was released in 1995 as a core component of the Java platform of Sun Microsystems. It is a general-purpose, class-based, object-oriented language that is widely used in application software and web applications.

Asked in Computer Viruses, Java Programming, iPhone 3GS

How do you get rid of Java-ByteVerify?

User Avatar
== == == == == == This is not a virus, but rather a method to exploit a security vulnerability in the Microsoft Virtual Machine. First, update to the latest version of Java Runtime Environment (JRE) - 6 Update 3 (as of June 2008. # Click on Start > Control Panel and double click on Add/Remove Programs. Locate Java 2 Runtime Environment, SE v1.4.2 and click on Change/Remove to uninstall it. # visit the SUN Java's website. http://java.sun.com/javase/downloads/index.jsp # Scroll down to Java Runtime Environment (JRE) 6 Update 3. Click on Download. # Select Accept License Agreement. The page will refresh. # Click on Windows Offline Installation, Multi-language and save it to a convenient location. # Run this installation to update your Java. 2) Run a windows update 3) Do a complete scan with a fully updated Anti virus Program.
Asked in Java Programming

Is java machine dependent?

User Avatar
Yes, since it can only play in some computers and not all computers can read it. Every Java application needs a minimum system configuration requirement which if not met, the machine will not be able to run Java. Java the language itself is NOT machine dependent. To run a program written in Java, it depends on an implementation of the Java Virtual Machine specification existing for a given machine/OS platform. Thus, a program written in Java can be run on any OS/machine platform for which a JVM has been created.
Asked in Technology, Bachelors Degrees, Graduate Degrees, Java Programming

Explain the usage of JPanel with example?

User Avatar
JPanel() : creates a new panel with flow layout. add(Component c) : adds component to a specified container. setLayout(LayoutManager l) : sets the layout of the container to specified layout manager. updateUI() : resets the UI property with a value from the current look and feel.
Asked in Web Programming, Java Programming

Write a java program to create a shopping bill?

User Avatar
import java.io.*; class ShopReceipt { protected static void main()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the no. of types of Items Purchased: "); byte z=Byte.parseByte(in.readLine()); String n[]=new String[z]; byte q[]=new byte[z]; float r[]=new float[z]; float pr[]=new float[z]; System.out.println("PLEASE ENTER::"); for(byte i=0;i<z;i++) { pr[i]=0; System.out.print("Name of Item: "); n[i]=in.readLine(); System.out.print("Rate of Item: "); r[i]=Float.parseFloat(in.readLine()); System.out.print("Quantity of Items: "); q[i]=Byte.parseByte(in.readLine()); pr[i]=r[i]*q[i]; } double t=0; for(byte i=0;i<z;i++) t+=pr[i]; for(byte i=0;i<z;i++) System.out.print("Item: "+n[i]+"\tQuantity: "+q[i]+"\tTotal Cost: "+pr[i]+"\n"); System.out.print("\nBill:"+t); if(t>=100&&t<500) System.out.print("\nGift::\nA Key Ring"); else if(t>=500&&t<1000) System.out.print("\nGift::\nA Leather Purse"); else if(t>=1000) System.out.print("\nGift::\nA Pocket Calculator"); }}
Asked in Java Programming, C Programming

What is the default return type of main?

User Avatar
'Main' is not at all associated with the return type. Specifying a function as main means that the function is to be executed first when the class is executed. A program can have only one 'main' function. Answer: The C standard ISO/IEC 9899 dictates that the return type of main() should be int. Edited by Vijay Duggirala It is void for Java. Which means that main in java returns no value.
Asked in Microsoft Windows, Java Programming, Numerical Analysis and Simulation, Python Programming

How do you code a program to find kaprekar number?

User Avatar
import java.io.*; class kaprekar { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter any number"); int n=Integer.parseInt(br.readLine()); int t=n,count=0; while(n!=0) { n=n/10; count++; } int s=t*t; int p=(int)Math.pow(10,count); int ld=s%p; int minus=s-ld; int fd=minus/p; int sum=fd+ld; if(sum==t) { System.out.println("Kaprekar Number"); } else { System.out.println("Not a Kaprekar number"); } } }
Asked in Java Programming, C Programming

What is an element in the Array?

User Avatar
An Array is a data type that stores multiple values in one variable. It can be thought of as a bunch of values that are related to one another and will be used together. Every value in the array is called an array element. They can be referred to or accessed by using their index position in the array.
Asked in Java Programming, Computer Programming

What are the advantages of platform independent programming languages?

User Avatar
A platform is a machine that interprets and executes code. Different platforms have different rules when interpreting code, as humans read different languages uniquely. Platform independent programming languages are universal, and can execute on all major machines. Programmers may write one script and needn't worry about target machinery. This is the sole advantage compared to platform dependent languages, which execute on a single machine. Unless a programmer would like the executable to work on one machine, additional work is necessary to bring it to other platforms.
Asked in Computer Programming, Java Programming, C Programming

Why are local variable stored on stack?

User Avatar
Because they are created and destroyed on 'last-in-first-out' principle.
Asked in Java Programming, How To

How to add a character to a string in java?

User Avatar
To add a Character to a string, simply use concatenation. When adding to strings, the + sign concatinates. Example: String one = "This is a strin"; one = one +'g'; /*OUTPUT : This is a string */ Note, that if you intend to modify a string frequently, you should NOT be using the String class. The String object is intended for fixed strings which never (or, extremely rarely) change contents. If you have a string in your program which you intend to modify frequently, use the StringBuffer class instead. It operates in the same manner as String, but the underlying implementation is completely different, and is tuned for faster string manipulation operations.
Asked in Java Programming, C Programming, Electrostatics

What is static?

User Avatar
A atom consist out of 2 parts where as the centre is called the nucleus which is form out of Protons and neutrons and the outer part that orbits the nucleus is Electrons. Protons is positively charged, Electrons is negatively charged and neutrons well you guessed it, its neutral. When 2 or more objects that is not earth bound is in constant contact or rubbed against each other, the Electrons from one of the objects is transferred to the other object and thus that object has more Electrons than Protons and thus it has a negative charge and the other object has a positive charge as it has no more Protons than Electrons. Protons doesn't normally get transferred from object to object as it is normally held firm to the Atom. Opposite objects attract each other while the same charge repel each other but a neutral object will attract both positive and negative charged objects. When a charged object is in contact with a different charged object a discharge will take place and thus static electricity will take place. Static menu: All patrons are offered the same foods every day. Once a static menu is developed and established, it rarely changes. Static menus are typically found in fast-food operations, ethnic restaurants, steakhouses and the like. Static menus can also be in institutional settings. For example, a static menu at an elementary school could offer students, along with vegetable and dessert, the same luncheon choices every school day: a cheeseburger, fish sticks, chicken tacos, pizza wedges or a sandwich.
Asked in Math and Arithmetic, Java Programming, C Programming

Why do we use double in java but do not use float?

User Avatar
Double is more precise than float. The 4 bytes saved on a float are usually not very relevant. However, if you need to save large amounts of numbers (e.g. in an array), and you don't need the extra precision, you might save some memory by using float.
Asked in Software and Applications (non-game), Computer Programming, Java Programming, Computer Science

What are the names of any four procedural programming languages?

User Avatar
ABC Ada Algol 60 Algol 68 APL Arc Assembly Awk BASIC Batch BCPL Befunge BETA C C++ C-- C# (pronounced C-sharp) CHILL Clipper Cobol CobolScript Component Pascal Cyclone D DATABUS Euphoria Forth Fortran Free Pascal GNU Pascal Icon IDL Jal JavaScript Jovial Lagoona Leda Limbo Lua m4 Maple Mathematica MATLAB Modula-2 Modula-3 Mumps Oberon Objective Caml (OCaml) Occam Oz-Mozart Pascal Perl PHP PL PL/1 Pliant PL/SQL PostScript PowerBuilder Proteus REBOL Rexx S-Lang Small C Snobol Tcl-Tk T3X VBA Visual Basic Visual DialogScript Yorick Note: Some of these languages, such as PHP, Perl, Caml/OCaml, and IDL also support object oriented programming. Others on the list (C++, JavaScript, C# ) are primarily object-oriented languages which can also (though less commonly) be used to program procedurally. Some are macro or scripting languages (Rexx, Awk, m4) which, while they do support some procedural concepts, aren't really procedural languages, but rather interpreted streams. Also note that Assembly is NOT a high-level language, and generally is not considered a procedural language, as it doesn't have enough abstraction. Finally, traditional COBOL is NOT a procedural language (in fact, one of the long-standing criticism of it is that it lacks any structured programming characteristics). Current-day COBOL has some ability to use procedural programming concepts, but, overall, should not be considered a real procedural language. SNOBOL is similar, in that the original version were certainly not procedural in nature, but modern versions are much more structured programming friendly (and can be considered a procedural language).
Asked in Java Programming

What is importance of static variable?

User Avatar
The static modifier tells the system that this particular variable belongs to the class and does not belong to any specific instance of the same. The class will contain only one instance of the static variable irrespective of how many objects of the class you create.
Asked in Java Programming

What is meant bu GUI in Java?

User Avatar
GUI stands for Graphical User Interface. The web browser in which you are viewing this website too can be considered a GUI to know more abt java i found out this amazing channel on youtube. its called as SLIDENEARD. Its a channel dedicated to java programming issues. i hope this helps your purpose.
Asked in Java Programming

Which data type in Java is the largest?

User Avatar
Among the primitive data types - float and double are the largest. Data TypeBits UsedMinimum ValueMaximum Valuebyte8-2727 - 1short16-215215 -1int32-231231 -1long64-263263 -1float32n/an/adouble64n/an/a
Asked in Java Programming, C++ Programming

What is a sample of default constructor?

User Avatar
A default constructor is a constructor that takes no arguments. Here's a sample: class c { int a,b; c() //Constructor 1 { a=2; b=1; } c(int x, int y) //Constructor 2 { a=x; b=y; } }; Here, Constructor 1 is called the default constructor, while Constructor 2 is a parameterized constructor.
Asked in Computer Programming, Java Programming

How class accomplish data hiding?

User Avatar
Data hiding is one of the important aspects of a class. Data hiding means to hide the members of the class and providing the access to only some of them. we can make the members of the class private or public. in private,the outside world cannot access those members which been made private.and rest we can make public.only the public members are accessed by the out side world and all the private members can be accessed using only the public members.in this way a class provides security to its data members.
Asked in Java Programming

Why java file name and public class name be same?

User Avatar
Because that is how Java file naming conventions are designed. The rules for naming files in Java are as follows: • There can be only one public class per source file. • Comments can appear at the beginning or end of any line in the source code file; they are independent of any of the positioning rules discussed here. • If there is a public class in a file, the name of the file must match the name of the public class. For example, a class declared as public class Rock { } must be in a source code file named Rock.java. • If the class is part of a package, the package statement must be the first line in the source code file, before any import statements that may be present. • If there are import statements, they must go between the package statement (if there is one) and the class declaration. If there isn't a package statement, then the import statement(s) must be the first line(s) in the source code file. If there are no package or import statements, the class declaration must be the first line in the source code file. • import and package statements apply to all classes within a source code file. In other words, there's no way to declare multiple classes in a file and have them in different packages, or use different imports. • A file can have more than one nonpublic class. • Files with no public classes can have a name that does not match any of the classes in the file.
Asked in Microsoft Windows, Java Programming, C Programming

What type of loop is the while loop?

User Avatar
It is also called as pretest loop.It executes the block of code after evaluation of condition in while statement.If evaluated answer is true,it will executes the block of code otherwise it will quit the loop.
Asked in Java Programming

What is reference data types in java?

User Avatar
A reference variable is used to refer to (or access) an object. A reference variable is declared to be of a specific type and that type can never be changed. Ex: ArrayList lst = new ArrayList(); The above line creates a reference variable lst which refers to an ArrayList object
Asked in Java Programming

What is the name of java interpreter?

User Avatar
That one is called "Java Virtual Machine".
Asked in Java Programming

What is class member in java?

User Avatar
A class has only two possible types of members: data members (variables) and member functions. In the Java lexicography, class variables are called its Attributes, and all class functions are called Methods.
Asked in Java Programming

Is Two method cannot have same name in java?

User Avatar
Two methods can have the same name provided their signature is different. Ex: public int add(int a, int b){ ... } public int add(int a, int b, int c){ ... } This is allowed whereas public int add(int a, int b){ ... } public int add(int a, int b){ ... } This is not. The above only applies within a single Class or Interface definition. It is entirely possible for different classes to have a method of the exact same signature (i.e. return value, method name, argument list). If a subclass has a method with the same signature as a parent class, then that method is said to have overridden the parent class's method. There is no specific name for the case where two unrelated classes have the same method signature, though that case is perfectly legal. Different signatures with the same method name are also allowed (which is called overloading when a subclass does it). Interfaces follow the same rules and conventions as Classes in this matter. ------------------- Two or more methods or constructor can have the same name provided they have different signature. In other words, when we can one of those methods, we should be able to tell which method was called even when they have the same name. You can read more about overloading constructors and methods on this page: http://www.javawithus.com/tutorial/overloading-constructors-and-methods
Asked in Computer Programming, Java Programming, C Programming

Is it possible to use the bubble sort algorithm to sort strings?

User Avatar
Bubble sort will be able to sort the items lexicographically, if you first assign the strings a relative value. The way strcmp in the C library does this is by returning the difference of the first different characters between the strings. For instance, if you call strcmp("Hello", "Highway"), strcmp will return 'e'-'i'. The ascii value of e on a unix system is 101 and the ascii value of i is 105, so it is returning the value 101-105 = -4 which will tell you that "Hello" is lexicographically smaller than "Highway". Doing this, you should be able to use any algorithm you want to sort the strings.