Object Oriented Programming Articles

Page 576 of 589

Java is also not pure object-oriented like c++

Pythonista
Pythonista
Updated on 30-Jul-2019 464 Views

the main() method in Java code is itself inside a class. The static keyword lets the main() method which is the entry point of execution without making an object but you need to write a class. In C++, main() is outside the class and writing class it self is not mandatory. Hence, C++ is not a pure object oriented language bu Java is a completely object oriented language.

Read More

compareTo() definition mistake?

Pythonista
Pythonista
Updated on 30-Jul-2019 227 Views

The example works correctly. The compareTo() method is called by a string object and takes another string object as argument. The return value is integer and is difference in Unicode values of characters of respective strings when they are not equal. The value can be -ve, 0 or +ve.

Read More

branching statement in Java

Kumar Varma
Kumar Varma
Updated on 30-Jul-2019 848 Views

Java programming language provides following types of decision making or branching statements.Java programming language provides following types of decision making statements.Sr.No.Statement & Description1if statementAn if statement consists of a boolean expression followed by one or more statements.2if...else statementAn if statement can be followed by an optional else statement, which executes when the boolean expression is false.3nested if statementYou can use one if or else if statement inside another if or else if statement(s).4switch statementA switch statement allows a variable to be tested for equality against a list of values.

Read More

Creating multiple Java objects by one type only

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

You can create a List of object easily. Consider the following example, where I'll create an array of Employee objects and print their details in a for loop. import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; public class Tester implements Cloneable { private int data; public int getData() { return data; } public void setData(int data) { this.data = data; } public Tester(int data){ ...

Read More

How to write string functions in Java?

Pythonista
Pythonista
Updated on 30-Jul-2019 201 Views

1) take a string from the user and check contains atleast one digit or not:Extract character array from string using toCharArray() method. Run a for loop over each character in array and test if it is a digit by static method isDigit() of character classpublic static boolean chkdigit(String str) { char arr[]=str.toCharArray(); for (char ch:arr) { if (Character.isDigit(ch)) { return true; } } return false; }2.) take ...

Read More

What does the bitwise left shift operator do in Java?

Monica Mona
Monica Mona
Updated on 30-Jul-2019 322 Views

The left operand value is moved left by the number of bits specified by the right operand.Example: A

Read More

What does the bitwise right shift operator do in Java?

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

The left operand value is moved right by the number of bits specified by the right operand.Example: A >> 2 = 15 means 1111.

Read More

What is the difference between >> and >>> operators in Java?

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

>> Binary Right ShiftThe left operand value is moved right by the number of bits specified by the right operand.>>> Shift right zero fillThe left operand value is moved right by the number of bits specified by the right operand and shifted values are filled up with zeros.

Read More

What is the difference between the size of ArrayList and length of Array in Java?

Srinivas Gorla
Srinivas Gorla
Updated on 30-Jul-2019 2K+ Views

ArrayList doesn't have length() method, the size() method of ArrayList provides the number of objects available in the collection.Array has length property which provides the length or capacity of the Array. It is the total space allocated during the initialization of the array.

Read More

How can we edit a java program?

Alankritha Ammu
Alankritha Ammu
Updated on 30-Jul-2019 822 Views

Java programs are simple text-based programs and can be edited using any text editor like notepad etc. The filename should be same as class name.

Read More
Showing 5751–5760 of 5,881 articles
« Prev 1 574 575 576 577 578 589 Next »
Advertisements