Object Oriented Programming Articles

Page 584 of 589

Can you use both this() and super() in a constructor in Java?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 2K+ Views

No, you cannot have both this() and super() in a single constructor.

Read More

What is the equivalent of C# namespace in Java?

usharani
usharani
Updated on 30-Jul-2019 410 Views

Packages are similar to namespaces in C#.

Read More

Why can't we override static methods in Java?

varma
varma
Updated on 30-Jul-2019 5K+ Views

Overloading is the mechanism of binding the method call with the method body dynamically based on the parameters passed to the method call.Static methods are bonded at compile time using static binding. Therefore, we cannot override static methods in Java.

Read More

What are tokens in Java?

Johar Ali
Johar Ali
Updated on 30-Jul-2019 2K+ Views

Java tokens are smallest elements of a program which are identified by the compiler. Tokens in java include identifiers, keywords, literals, operators and, separators.

Read More

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 702 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 863 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 475 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 272 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 729 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
Showing 5831–5840 of 5,881 articles
« Prev 1 582 583 584 585 586 589 Next »
Advertisements