Skip to main content

Posts

Showing posts from August, 2023

Understand the Data Type of String Class In java || Methods of String

String: String is a non primitives' data type hota hai string ka size fix nhi hota hai  String is sequence of character (Array of Character) String is a Class  String bnane ke liye hamare pas 3 classes hote hai  >> String buffer >> String builder  >> String public final class String extends objects charSequence  {    } toUpperCase () - - - - - - - - - > Kisi bhi lowercase string to Upper case me convert krne ke liye java me toUpperCase method ka use krte hai. > Yah ek method hai java ka,isme Camel case naming convention ka use hota hai Example - - - public static void main ( String [] args ) { String a = "divyanshu" ; System . out . print ( a . toUpperCase ()) ; toLowerCase() - - - - - - > Kisi bhi uppercase ke string ko lower case me transform krne ke liye toLowerCase method ka use hota hai. > Yah ek method hai java ka , isme Camel Case naming convention ka use hota hai . Example ---- public static void main ( String [

Question Practice Chapter 3 Java

Question: Write a Java program to Convert a String in Lowercase. Ans: package HelloWorld ; import java . util . Scanner ; public class LearningJava { // write a java program to convert a string to lowercase ; public static void main ( String [] args ) { Scanner scan = new Scanner ( System . in ) ; System . out . print ( "Give a String in Upper Case:" ) ; String str = scan . nextLine () ; System . out . print ( str . toLowerCase ()) ; } } yaha ham ek Scanner class le rhe hai jo ki predefined class hai  String str name se ek string liya hai  str.toLowerCase ek method hai jo ki kisi bhi string ko lowercase me convert krta hai aur ise ham camel convention me likhte hai  Question: Write a Java program to convert a string in Uppercase Ans: package  HelloWorld ; import  java . util . Scanner ;   //this is a predefined scanner class for take //input from user public   class   LearningJa

Practice Question Chapter 1 - - - - - In Java

 Question: write a java program to print three numbers in java . Ans:  package HelloWorld ; import java . util . Scanner ; public class LearningJava { public static void main ( String [] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt () ; int b = scan . nextInt () ; int c = scan . nextInt () ; int sum = ( a + b + c ) ; System . out . println ( sum ) ; } } ----------------------------------------------------------------------------------------------------------------------------  Question:2 write a java program to calculate cgpa using marks of three Subjects out of 100. Ans: package HelloWorld ; import java . util . Scanner ; public class LearningJava { public static void main ( String [] args ) { //Question: write a java program to calculate // cgpa using marks of three Subjects out of 100. Scanner

Java Cheat Sheet by Code With Harry

Basics Basic syntax and functions from the Java programming language. Boilerplate class HelloWorld { public static void main ( String args [ ] ) { System . out . println ( "Hello World" ) ; } } Copy Showing Output It will print something to the output console. class HelloWorld { public static void main ( String args [ ] ) { System . out . println ( "Hello World" ) ; } } Copy Taking Input It will take string input from the user import java . util . Scanner ; class HelloWorld { public static void main ( String args [ ] ) { Scannner sc = new Scanner ( System . in ) ; String name = sc . nextLine ( ) ; System . out . println ( name ) ; } } Copy It will take integer input from the user import java . util . Scanner ; class HelloWorld { public static void main ( String args [ ]