Forwarded from java interview Questions (Raj patel)
Strings in Java
Strings in Java are Objects that are backed internally by a char array. Since arrays are immutable(cannot grow), Strings are immutable as well. Whenever a change to a String is made, an entirely new String is created.
Below is the basic syntax for declaring a string in Java programming language.
Syntax: String str = "learnJava";
More java Interview Questions Visit:- https://cjavapoint.blogspot.com/ ππππππ
Strings in Java are Objects that are backed internally by a char array. Since arrays are immutable(cannot grow), Strings are immutable as well. Whenever a change to a String is made, an entirely new String is created.
Below is the basic syntax for declaring a string in Java programming language.
Syntax: String str = "learnJava";
More java Interview Questions Visit:- https://cjavapoint.blogspot.com/ ππππππ
π3β€1
8.1 What is the difference between a Choice and a List ?
A Choice is displayed in a compact form that must be pulled down, in order for a user to be able to see the list of all available
choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible.
A List supports the selection of one or more List items.
8.2
What is a layout manager ?
A layout manager is the used to organize the components in a container.
8.3
What is the difference between a Scrollbar and a JScrollPane ?
A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs
its own scrolling.
8.4
Which Swing methods are thread-safe ?
There are only three thread-safe methods: repaint, revalidate, and invalidate.
8.5
Name three Component subclasses that support painting.
The Canvas, Frame, Panel, and Applet classes support painting.
8.6
What is clipping ?
Clipping is defined as the process of confining paint operations to a limited area or shape.
8.7
What is the difference between a MenuItem and a CheckboxMenuItem ?
The CheckboxMenuItem class extends the MenuItem class and supports a menu item that may be either checked or unchecked
A Choice is displayed in a compact form that must be pulled down, in order for a user to be able to see the list of all available
choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible.
A List supports the selection of one or more List items.
8.2
What is a layout manager ?
A layout manager is the used to organize the components in a container.
8.3
What is the difference between a Scrollbar and a JScrollPane ?
A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs
its own scrolling.
8.4
Which Swing methods are thread-safe ?
There are only three thread-safe methods: repaint, revalidate, and invalidate.
8.5
Name three Component subclasses that support painting.
The Canvas, Frame, Panel, and Applet classes support painting.
8.6
What is clipping ?
Clipping is defined as the process of confining paint operations to a limited area or shape.
8.7
What is the difference between a MenuItem and a CheckboxMenuItem ?
The CheckboxMenuItem class extends the MenuItem class and supports a menu item that may be either checked or unchecked
π17β€4
public class RemoveNonASCIIString{
public static void main(String [] args){
String str = "InstanceΒ‘ofΒ₯java";
System.out.println(str);
str = str.replaceAll("[^\\p{ASCII}]", "");
System.out.println("After removing non ASCII chars:");
System.out.println(str);
}
}
public static void main(String [] args){
String str = "InstanceΒ‘ofΒ₯java";
System.out.println(str);
str = str.replaceAll("[^\\p{ASCII}]", "");
System.out.println("After removing non ASCII chars:");
System.out.println(str);
}
}
π4β€1
import java.util.Arrays;
import java.util.LinkedHashSet;
public class ArrayExample
{
public static void main(String[] args) throws CloneNotSupportedException
{
//Array with duplicate elements
Integer[] numbers = new Integer[] {1,2,3,4,5,1,3,5};
//This array has duplicate elements
System.out.println( Arrays.toString(numbers) );
//Create set from array elements
LinkedHashSet<Integer> linkedHashSet = new LinkedHashSet<>( Arrays.asList(numbers) );
//Get back the array without duplicates
Integer[] numbersWithoutDuplicates = linkedHashSet.toArray(new Integer[] {});
//Verify the array content
System.out.println( Arrays.toString(numbersWithoutDuplicates) );
}
}
import java.util.LinkedHashSet;
public class ArrayExample
{
public static void main(String[] args) throws CloneNotSupportedException
{
//Array with duplicate elements
Integer[] numbers = new Integer[] {1,2,3,4,5,1,3,5};
//This array has duplicate elements
System.out.println( Arrays.toString(numbers) );
//Create set from array elements
LinkedHashSet<Integer> linkedHashSet = new LinkedHashSet<>( Arrays.asList(numbers) );
//Get back the array without duplicates
Integer[] numbersWithoutDuplicates = linkedHashSet.toArray(new Integer[] {});
//Verify the array content
System.out.println( Arrays.toString(numbersWithoutDuplicates) );
}
}
β€2π1
240-core-java-interview-questions-and-answers.pdf
502.6 KB
π4β€1π1
π1
Hello aap sabhi ko mera pranam
Kis ka material jyada chaiye bataye
Apne Chanel ko share jarur kare
Kis ka material jyada chaiye bataye
Apne Chanel ko share jarur kare
Anonymous Poll
89%
Java
2%
C language
1%
C++
2%
Angular js
5%
Java script
1%
Any other
π10β€2