Programming Articles

Page 2544 of 2546

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

How to check a String for palindrome using arrays in java?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 9K+ Views

To verify whether the given string is a palindrome (using arrays) Convert the given string into a character array using the toCharArray() method. Make a copy of this array. Reverse the array. Compare the original array and the reversed array. in case of match given string is a palindrome. Example import java.util.Arrays; import java.util.Scanner; public class Palindrome { public static void main(String args[]) { System.out.println("Enter a string "); Scanner sc = new Scanner(System.in); String s ...

Read More

How do I write package names in Java?

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

While choosing a package name you need to keep the following points in mind. The name of the package should be in small letters. It is suggested to start the name of the package with the top level domain level followed by sub domains, ex: com.example.tutorialspoint. Example You can declare a package as in. package com.mypackage.tutorialspoint; Public class Sample { Public static void main(String args[]) { System.out.println("Welcome to Tutorialspoint"); } } Executing a package You need to compile the file with packages using –d ...

Read More

Is final method inherited in Java?

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

No, we cannot override a final method in Java. The final modifier for finalizing the implementations of classes, methods, and variables. We can declare a method as final, once you declare a method final it cannot be overridden. So, you cannot modify a final method from a sub class. The main intention of making a method final would be that the content of the method should not be changed by any outsider. Example class Demo{ public final void demoMethod(){ System.out.println("Hello"); } } public class Sample extends Demo{ ...

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 to add items to an array in java dynamically?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 11K+ Views

Since the size of an array is fixed you cannot add elements to it dynamically. But, if you still want to do it then, Convert the array to ArrayList object.Add the required element to the array list.Convert the Array list to array.Exampleimport java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class AddingItemsDynamically {    public static void main(String args[]) {       Scanner sc = new Scanner(System.in);       System.out.println("Enter the size of the array :: ");       int size = sc.nextInt();       String myArray[] = new String[size];       System.out.println("Enter elements of the array ...

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 BLOB to Byte Array in java?

Ramu Prasad
Ramu Prasad
Updated on 30-Jul-2019 8K+ Views

You can contents of a blob into a byte array using the getBytes() method.Exampleimport java.awt.Image; import java.awt.image.BufferedImage; import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.Arrays; public class BlobToByteArray { public static void main(String[] args) throws Exception { Image image = new BufferedImage(300, 400, BufferedImage.TYPE_INT_RGB); String JDBC_DRIVER = "com.mysql.jdbc.Driver"; String DB_URL = "jdbc:mysql://localhost/mydb"; String USER = "root"; String PASS = "password"; ...

Read More
Showing 25431–25440 of 25,451 articles
Advertisements