Why you start java program by class?
without class non of the folder can run so the java program should start in class we can use the class without object in java
The main method of a program has?
The Java main method of a program is the place where the program execution begins. A main method would look like below
public static void main(String[] args){
}
What is inline thread in java?
You can start a thread "inline" without implementing Runnable or extending Thread class
( new Thread() { public void run()
{
// do something
} } ).start();
What is adapter in programming language?
An adapter is a class that subclasses a commonly used class or interface with reasonable default functions provided. For example, the WindowAdapter provides a quick solution that provides default do-nothing functions for 4 common interfaces that a GUI would use. Typically, a developer only needs one or two functions from WindowEvent, for example, but without an adapter, they are required to implement seven functions (with five or six of them "do-nothing" functions), instead of just using an adapter and providing the one or two function bodies they do need.
When do you override the finalize method?
when there is cleanup activity needed before an object is destroyed
What is the default initial value for all numeric types?
If they are instance variables the default initial value is 0. If they are method local variables, they are null and must be initialized to some value before they are used
JSF, not very well known
JSF, Probably a strict-typed language and therefore difficult for beginners
JSF, Did i mention not very well known?
PHP, Very well known
PHP, Forgiving (also error prone, lets be fair)
PHP, Lots of community support
What does program interface mean?
A program interface refers to the set of rules and conventions that allow different software components to communicate with each other. It defines the methods, inputs, outputs, and data formats for interaction, enabling integration and interoperability between systems. Program interfaces can take various forms, including application programming interfaces (APIs), user interfaces (UIs), and command-line interfaces (CLIs). Well-designed interfaces enhance usability and facilitate the development and maintenance of software applications.
What is advantage of overloading main method?
Practically speaking, there is no advantage in overloading the main method because, eitherways the main method of the current class only gets executed and not any of the parent classes, the current class might extend.
What program can be written to count the number of alphanumerics in a string?
public int getStringLength(String val) {
return val.length();
}
There is an inbuilt functionality in strings that counts the number of alphabets in a string called length()
What is the difference between class and struct?
The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, a struct is more efficient in some scenarios. For example, if you declare an array of 1000 Point objects, you will allocate additional memory for referencing each object. In this case, the struct is less expensive.
When we create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized.
It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values.
It is an error to initialize an instance field in a struct.
There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do.
A struct is a value type, while a class is a reference type.
Write a program using recursion which should take two values and display 1st value raised to the power of second value.
What is the Java source code for the program which print the prime no series?
public class PrimeNumberPrint {
/**
* @param args
*/
public static voidmain(String[] args) {
// TODO Auto-generated method stub
for(int i =2; i < 10; i++) {
System.out.println(i + " is prime is " + isPrime(i));
}
}
public static booleanisPrime(int n) {
int x = n;
for(int i=2; i if(n%i == 0) { return false; } } return true; } }
What happens when your compare two string objects with the equals operator?
Yes, the if the two string objects point to the same memory location. But "==" is not the best way to compare two string objects. Two strings can be compared using obj1.equals(obj2). This compares for the textual equal-ness of the two string objects.
What can be used to read input from the keyboard?
I don't know excactly what you are meaning by input from keyboard. Do you mean if they enter a key, something are going to happen or do you mean that they can type in some text and then you are trying to get the text they have typed?
If you are trying to get something happen when they press a key, use a KeyListener.
If you are going to get some text they are typing into your program you have to use scanner. Scanner can be imported from java.util.Scanner.
What facility static gives in class?
Static variables or function provides global view to the application that is u can access a static variable with one or more than one objects of a single class without loosing i.e. reinitializing its value.
Basically packaged food is food that can be shipped somewhere. And the reason that they are packaged is because so they can be safe and keep out germs.
default constructor is used only when the programmer does not use a constructor to initialize objects. Once the programmer defines a constructor then the default constructor is no longer used
Does there exists any other function which can be used to convert an integer or a float to string?
jkhhg ldsajdsa dlsajaslsala laja alala alala alalaalal alal alal alala a;ala aja,a