Java Articles

Page 446 of 450

Can a Java array be declared as a static field, local variable or a method parameter?

Rahul Sharma
Rahul Sharma
Updated on 30-Jul-2019 698 Views

We can declare an array as a local variable or method parameter but, an array cannot be static. Example public class Test{ public void sample(){ static int[] myArray = {20, 30}; System.out.println(); } public static void main(String args[]){ Test t = new Test(); t.sample(); } } Error C:\Sample>javac Test.java Test.java:3: error: illegal start of expression static int[] myArray = {20, 30}; ^ 1 error

Read More

Can access modifiers be used for local variables in Java?

Arushi
Arushi
Updated on 30-Jul-2019 857 Views

Yes, a local variable can be public, private, protected or default.

Read More

What is the difference between a String object and a String literal in Java?

Paul Richard
Paul Richard
Updated on 30-Jul-2019 1K+ Views

When the String literal used to create String, JVM initially checks weather String with the same value in the String constant pool, if available it creates another reference to it else it creates a new object and stores it in the String constant pool.In case of an object, each time you instantiate the class a new object is created given value irrespective of the contents of the String constant pool.

Read More

What is the difference between a String object and a StringBuffer object in java?

Rishi Raj
Rishi Raj
Updated on 30-Jul-2019 469 Views

String class is immutable once you create an object of string you can modify its data.The StringBuffer class is immutable, once you create a StringBuffer object you can change/modify the contents of it.This class provides various methods to manipulate its data such as append(), delete(), insert() etc.

Read More

What are the different build tools in Java?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 266 Views

"On a mean, a developer spends a considerable quantity of your time doing mundane tasks compiling the code, packaging the binaries, deploying the binaries to the checkserver, testing the changes," copying the code from one location to another. To automate and simplify these tasks we can use build tools like Ant, Maven, Gradle etc.

Read More

Is it necessary that a try block should be followed by a catch block in Java?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 728 Views

Not necessarily catch, a try must be followed by either catch or finally block. Example import java.io.File; public class Test{ public static void main(String args[]){ System.out.println("Hello"); try{ File file = new File("data"); } } } Output C:\Sample>Javac Test.java Test.java:5: error: 'try' without 'catch', 'finally' or resource declarations try{ ^ 1 error

Read More

What is the Eclipse keyboard shortcut for "System.out.println()" in Java?

Govinda Sai
Govinda Sai
Updated on 30-Jul-2019 15K+ Views

To get System.out.println() line in eclipse without typing the whole line type sysout and press Ctrl + space.

Read More

When a thread is created and started, what is its initial state?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 595 Views

When a new thread begins its life cycle in the new state. It remains in this state until the program starts the thread. It is also referred to as a born thread.After this newly born thread is started, the thread becomes runnable. A thread in this state is considered to be executing its task.

Read More

Way to check if SAP system is ABAP based, Java or Dual stack

Rahul Sharma
Rahul Sharma
Updated on 30-Jul-2019 2K+ Views

Using SAP GUI, you can only access ABAP or ABAP+Java based system. You can check at multiple places if it is a dual system.T-code: SMICM, you can checklist of services in transaction SMICM (Goto --> Services) - dual stack systems will have the J2EE services listed too. There will also be an AS Java menu in SMICM on ABAP+Java systems.

Read More

Difference between Java SE, Java EE, and Java ME?

mkotla
mkotla
Updated on 30-Jul-2019 2K+ Views

Java provides three editions JSE, JEE, JME. JSE − Java Standard Edition using this, you can develop stand-alone applications. This provides the following packages − java.lang − This package provides the language basics. java.util − This package provides classes and interfaces (API’s) related to collection framework, events, data structure and other utility classes such as date. java.io − This package provides classes and interfaces for file operations, and other input and output operations. java.math − This package provides classes and interfaces for multiprecision arithmetics. java.nio − This package provides classes and interfaces the Non-blocking I/O framework for Java java.net ...

Read More
Showing 4451–4460 of 4,498 articles
« Prev 1 444 445 446 447 448 450 Next »
Advertisements