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

What is concrete method?

class in which objects can be created is called as concrete class.

PASCAL compiler is written in which language?

Which Pascal compiler do you mean? Pascal compiler can be written in Pascal, of course.

Which of the two types of Data Independence Types is harder to achieve?

The ability to modify a scheme definition in one level without affecting a scheme definition in next higher level is called data independence

there are two types of data independence

physical data independence:- refers to the ability to modify the scheme followed at the physical level without affecting the scheme followed at logical level

logical data independence:- refers to the ability to modify the conceptual scheme without affecting the schemes followed at view level

logical independence is difficult to achieve

1 Write a Java program to find x to the power y Use overloading for different cases when x and y are combination of integer and floating point numbers?

In practice, it is better to use the Math class, which already has a pow() (i.e., power) function. If you want to program it yourself, just write a loop:

double myPower(double x, int y)
{
double result = 1;
for (int i = 1; i <= y; i++)
result *= x;

return result;

}

For overloading, simply repeat with different arguments. You might also re-use the method created previously, like this:

int myPower(int x, int y) {return (int) myPower(x, y) }

Why do persistent programming language allow transient object?

If you mark an instance variable as transient, you're telling the JVM to skip (ignore) this variable when you attempt to serialize the object containing it. Don't worry about Serialization just yet. That is a cool feature of java that we shall be seeing in greater detail in one of the subsequent chapters. For not it is enough to know that a transient variable will be ignored when the object is serialized.

What are primitive variables?

Primitive variables are variables that are not objects and carry primitive values like numbers, boolean etc. The primitive data types in java are:

  • int
  • byte
  • float
  • char
  • long
  • boolean
  • short
  • double

Can you compile interface in java?

In Java, you cannot compile an interface directly because interfaces themselves are not executable; they are meant to define a contract for classes that implement them. However, you can compile the interface along with the implementing classes. When you compile a Java program, the Java compiler generates bytecode for all classes and interfaces, which can then be executed by the Java Virtual Machine (JVM).

What is avribation of J2EE?

J2EE, or Java 2 Platform, Enterprise Edition, is a set of specifications from Sun Microsystems (now part of Oracle) that extends the Java SE (Standard Edition) with specifications for enterprise features such as distributed computing and web services. It provides a robust environment for developing and deploying large-scale applications, particularly those that require scalability, reliability, and security. J2EE includes technologies like Servlets, JSP (JavaServer Pages), EJB (Enterprise JavaBeans), and more, facilitating the development of multi-tiered, web-based applications.

What is immediate exception?

An immediate exception refers to a situation where an error or anomaly occurs in a system or process that requires urgent attention and resolution. This can happen in various contexts, such as programming, where an immediate exception might halt the execution of a program until the issue is addressed. It often indicates a critical failure that cannot be ignored, necessitating prompt intervention to restore normal functionality.

What method in java performs some action (i.e. not assignments) other than returning a value?

Methods that are neither mutators (setters) or accessors (getters). This primarily includes the class constructors (the initialisers) and the class destructor (the restorer).

How do you find the average of rows and columns in a 2d array in java?

You add up all the array elements, then divide by the number of elements. You can use a nested for() loop in Java; inside the inner for() loop, you can both increase a counter (to count how many elements there are), and add to a "sum" variable.

Java program to arrange any numbers in ascending order using scanner classes?

To arrange numbers in ascending order using Java, you can utilize the Scanner class to read input from the user and then sort the numbers using an array. Here's a simple example:

import java.util.Arrays;
import java.util.Scanner;

public class AscendingOrder {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter the number of elements: ");
        int n = scanner.nextInt();
        int[] numbers = new int[n];

        System.out.println("Enter the numbers:");
        for (int i = 0; i < n; i++) {
            numbers[i] = scanner.nextInt();
        }

        Arrays.sort(numbers);
        System.out.println("Numbers in ascending order: " + Arrays.toString(numbers));
        scanner.close();
    }
}

This program collects a specified number of integers from the user, sorts them using Arrays.sort(), and then displays the sorted list.

Simple example What is class inheritance?

A Scenario where one class is inheriting/extending the behavior of just one super class.

Ex: public class Ferrari extends Car {…}

Here the Ferrari class is using features/logic from the Car class

When was Sea Pole class bathyscaphe created?

Sea Pole class bathyscaphe was created in 2009.

When was Scenes from the Class Struggle in Springfield created?

Scenes from the Class Struggle in Springfield was created on 1996-02-04.

When was Exception to the Rule created?

Exception to the Rule was created on 1997-04-05.

What are getters and setters method?

Getter method: A getter method have its name start with 'get', and take 0 parameters, and also returns a value. Setter method: A setter method have its name start with "set", and takes 1 parameter. Setters may or may not return a value. Some setters return void, some the value set.

What is the concept of class file?

That means: the file where a class is stored.

What is a use of dereferencing operator?

A pointer variable contains the address to some memory location. "Dereferencing" the pointer means getting the value stored at that memory location.

Why doesn't the string class have to be imported into your programs?

The String class is part of java.langpackage which is automatically and implicitly imported in all classes. In other words, adding the statement "import java.lang.String" is redundant.

What are the 6 ways to use this keyword?

"Java This keyword" is a reference to the current object, it is very helpful when you need to refer an instance of a particular Object from its available methods or using it's constructor, also "this" keyword helps us to avoid naming conflicts.

The following are different ways to use java this keyword

  • 1) Using with instance variable
  • 2) Using with Constructor
  • 3) Pass / Return current instance
  • Using with instance variable

    Using this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variable

  • Using with instance variable

    Using this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variable

  • Using with Constructor

    Using this keyword inside constructor like following

    this("Sony", 20);

    it will call the constructor having same parameter