Maruthi Krishna has Published 870 Articles

What happens if try to access an element with an index greater than the size of the array in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 12:20:04

3K+ Views

An array is a data structure/container/object that stores a fixed-size sequential collection of elements of the same type. The size/length of the array is determined at the time of creation.The position of the elements in the array is called as index or subscript. The first element of the array is stored ... Read More

Can you pass the negative number as an Array size in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 12:18:45

3K+ Views

In general, arrays are the containers that store multiple variables of the same datatype. These are of fixed size and the size is determined at the time of creation. Each element in an array is positioned by a number starting from 0.You can access the elements of an array using ... Read More

Can you assign an Array of 100 elements to an array of 10 elements in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 12:14:32

3K+ Views

In general, arrays are the containers that store multiple variables of the same datatype. These are of fixed size and the size is determined at the time of creation. Each element in an array is positioned by a number starting from 0.You can access the elements of an array using ... Read More

What are the best practices to keep in mind while using packages in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 12:11:58

862 Views

You can create the .class files of all the Java classes and interfaces related to each other in one folder automatically by declaring them under same package. A package is nothing but a directory storing classes and interfaces of a particular concept.Creating a packageYou can create a package and add ... Read More

How to read a single character using Scanner class in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 11:52:39

2K+ Views

From Java 1.5 Scanner class was introduced. This class accepts a File, InputStream, Path and, String objects, reads all the primitive data types and Strings (from the given source) token by token using regular expressions. By default, whitespace is considered as the delimiter (to break the data into tokens).Reading a ... Read More

Difference between import and package in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 11:50:24

3K+ Views

In Java classes and interfaces related to each other are grouped under a package. Package is nothing but a directory storing classes and interfaces of a particular concept. For example, all the classes and interfaces related to input and output operations are stored in java.io package.Creating a packageYou can group ... Read More

How do you print the content of an array in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 11:49:24

501 Views

In general, arrays are the containers that store multiple variables of the same datatype. These are of fixed size and the size is determined at the time of creation. Each element in an array is positioned by a number starting from 0.You can access the elements of an array using ... Read More

Can you use a switch statement around an enum in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 11:48:07

1K+ Views

Enumeration (enum) in Java is a datatype which stores a set of constant values. You can use enumerations to store fixed values such as days in a week, months in a year etc.enum Days {    SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }You can also define an enumeration with ... Read More

Difference between the byte stream and character stream classes in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 10:37:19

5K+ Views

Java provides I/O Streams to read and write data where, a Stream represents an input source or an output destination which could be a file, i/o devise, other program etc.Based on the data they handle there are two types of streams −Byte Streams − These handle data in bytes (8 ... Read More

Write a program to print message without using println() method in java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 10:34:27

7K+ Views

The println() method of the System class accepts aStringas parameter an prints the given String on the console.Examplepublic class PrintData {    public static void main(String args[]) {       System.out.println("Hello how are you");    } }OutputHello how are youIn addition to this you can print data on the ... Read More

Advertisements