Java Articles

Page 444 of 450

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 656 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 655 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 729 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 678 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

What is a composition in Java?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 30-Jul-2019 431 Views

The composition is also a type of aggregation where the relationship is restrictive i.e. If two objects are in composition, the composed object will not exist without the other.

Read More

What is the difference between compositions and aggregations in Java?

Sharon Christine
Sharon Christine
Updated on 30-Jul-2019 289 Views

In Aggregation relationship among classes by which a class (object) can be made up of any combination of objects of other classes. It allows objects to be placed directly within the body of other classes.A composition is also a type of aggregation where the relationship is restrictive i.e. If two objects are in composition, the composed object will not exist without the other.

Read More

What are native methods in Java and where are they used?

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

A native method in Java is a method whose implementation is written in other languages such as c and c++. The ‘native’ keyword is used before a method to indicate that it is implemented in other language.

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