answersLogoWhite

0

📱

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.

5,203 Questions

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 Vs PHP?

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.

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.

What is package?

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.

When a object is passed to a function as argument why it is not generating an error if the parameterized constructor is defined and not the default constructor?

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

What is sparce array?

sparse array is one which has contents lower than its maximum size, that is the array has free or empty locations....

What is AppletStub Interface?

The applet stub interface provides the means by which an applet and the browser communicate. Your code will not typically implement this interface

What is the meaning of the word methods?

Methods is defined as a procedure for approaching something. For example, you think of a method of how you are going to finish certain tasks which you need to get done at night.

What are limitations of double indicator method?

I know I know!!!! Its my fat juicy coc that you gotta slurp to get the answer.