1) What are Primitive and Non-Primitive Data Types?
Answer: The below is the answer for this question:
Data Types that are non-object oriented are know as Primitive Data Types.
Examples for Primitive Data Type: byte,short,int,long,float,double,char and boolean
Data Types that are object oriented are known as Non-Primitive Data Types.
Examples for Non-Primitive Data Type: String, Array, Classes etc.
Non-Primitive Data Types are also know as Reference Data Types.
For detailed answer with practical examples and explanation of this answer, you can check the below youtube video:
2) What is the operator using with we can perform both Concatenation and Addition operations?
Answer: The below is the answer for this question:
The operator having symbol + can be used for performing both Concatenation and Addition operations.
For detailed answer with practical examples and explanation of this answer, you can check the below youtube video:
3) What is the difference between length and length()?
Answer: The below is the answer for this question:
length is a predefined variable in Java, which can be used for finding the size of the an Array.
Whereas, length() is a predefined method of String class, which can be used for finding the size of the given String text.
For detailed answer with practical examples and explanation of this answer, you can check the below youtube video:
4) Write a Java program to find whether the given word is available in the given paragraph?
Answer: The below is the answer for this question:
The below is the code for finding whether the given word is available in the given paragraph:
public class Demo { public static void main(String[] args) { String s = "This is a sample text written by Arun Motoori" ; String searchText = "Arun" ; if(s.indexOf(searchText)!=-1) { System.out.println("Yes, given text is available in the paragraph"); } else { System.out.println("No, the given text is not available in the paragraph"); } } }
For detailed answer with practical examples and explanation of this answer, you can check the below youtube video:
5) Why Primitive Data Types are not Object Oriented?
Answer: The below is the answer for this question:
For reducing the memory being occupied and to improve the performance for performing basic and mostly used operations.
For detailed answer with practical examples and explanation of this answer, you can check the below youtube video:
6) What are the different types of Modifiers in Java?
Answer: The below is the answer for this question:
Modifier in Java can be categorized at a high level into two types:
- Access Modifiers
- Non-Access Modifiers
List of Access Modifiers: public, private, protected and default
List of Non-Access Modifiers: static, final and abstract
For detailed answer with practical examples and explanation of this answer, you can check the below youtube video:
7) What is the difference between private and public access modifiers?
Answer: The below is the answer for this question:
private access modifier specified variables and methods, cannot be accessed outside the class.
Where as, public access modifier specified variables, methods and Classes can be accessed outside the class too.
For detailed answer with practical examples and explanation of this answer, you can check the below youtube video:
8) What is the difference between default and protected access modifiers?
Answer: The below is the answer for this question:
default access modifier specified variables, methods and classes, are public to all the Classes which are in the same package, where as private to all the Classes which are outside the package.
Where as, protected access modifier is also same as default access modifier, except the sub classes outside the package can still access the protected specified variables and methods.
For detailed answer with practical examples and explanation of this answer, you can check the below youtube video:
9) How to access static variables and methods?
Answer: The below is the answer for this question:
static variable and methods inside the classes needs to be accessed using the Class Name.
And variables in an Interface are by default static, and hence they needs to be accessed using the Interface Name.
For detailed answer with practical examples and explanation of this answer, you can check the below youtube video:
10) How to access instance variables and methods?
Answer: The below is the answer for this question:
Instance variables and methods inside the classes needs to be accessed using Object reference of the Class in which they are created.
For detailed answer with practical examples and explanation of this answer, you can check the below youtube video:
Please leave your questions/comments/feedback below.
Happy Learning 🙂
Arun Motoori ( www.QAFox.com )