Java Articles

Page 444 of 450

How do I write method names in Java?

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

While writing a method name we should follow the camel case i.e. first letter of the first word should be small and the first letters of the remaining (later) words should be capital. Example public class Test { public void sampleMethod() { System.out.println("This is sample method"); } public void demoMethod() { System.out.println("This is demo method"); } public static void main(String args[]) { Test obj = new Test(); obj.sample(); obj.demo(); } } Output This is sample method This is demo method

Read More

Are there inline functions in Java?

vanithasree
vanithasree
Updated on 30-Jul-2019 4K+ Views

If a function is inline, the compiler places a copy of the code of that function at each point where the function is called at compile time. Any change to an inline function could require all clients of the function to be recompiled because compiler would need to replace all the code once again otherwise it will continue with old functionality. No, Java does not provide inline functions it is typically done by the JVM at execution time.

Read More

Are 'this' and 'super' keywords in Java?

Prabhas
Prabhas
Updated on 30-Jul-2019 451 Views

Yes, this and super are keywords in Java. Where ‘this’ is used as a reference of the current object and, ‘super’ is used as a reference to the superclass object.

Read More

Is main a keyword in Java?

varun
varun
Updated on 30-Jul-2019 1K+ Views

No, main is not a keyword in Java.

Read More

Is null a keyword in Java?

usharani
usharani
Updated on 30-Jul-2019 657 Views

No, null is not a keyword. Though they seem like keywords null, true and, false are considered as literals in Java.

Read More

How (where) are the elements of an array stored in memory?

Priya Pallavi
Priya Pallavi
Updated on 30-Jul-2019 2K+ Views

In Java, arrays are objects, therefore just like other objects arrays are stored in heap area. An array store primitive data types or reference (to derived data) types Just like objects the variable of the array holds the reference to the array.

Read More

How to convert a byte array to a hex string in Java?

Abhinaya
Abhinaya
Updated on 30-Jul-2019 665 Views

The printHexBinary() method of the DatatypeConverter class accepts a byte array and returns a hex string.Exampleimport javax.xml.bind.DatatypeConverter; public class ByteToHexString { public static void main(String args[]) { String sam = "Hello how are you how do you do"; byte[] byteArray = sam.getBytes(); String hex = DatatypeConverter.printHexBinary(byteArray); System.out.println(hex); } }Output48656C6C6F20686F772061726520796F7520686F7720646F20796F7520646F

Read More

How to declare a class in Java?

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

Following is the syntax to declare a class. class className { //Body of the class } You can declare a class by writing the name of the next to the class keyword, followed by the flower braces. Within these, you need to define the body (contents) of the class i.e. fields and methods.To make the class accessible to all (classes) you need to make it public. public class MyClass { //contents of the class (fields and methods) }

Read More

Why do Java array declarations use curly brackets?

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

Curly brackets usually denote sets and ensembles while parenthesis usually in most Algol-based programming languages curly braces are used to declare arrays.

Read More

Why are classes sometimes declared final in Java?

Sreemaha
Sreemaha
Updated on 30-Jul-2019 680 Views

If a class is declared final, you cannot inherit it. If you try it gives you a compile-time error as − Example final class Super { private int data = 30; } public class Sub extends Sub { public static void main(String args[]){ } } Output Exception in thread "main" java.lang.Error: Unresolved compilation problem: at Sub.main(Sub.java:7)

Read More
Showing 4431–4440 of 4,498 articles
« Prev 1 442 443 444 445 446 450 Next »
Advertisements