Java Fundamentals Quiz

Source: Internet
Author: User

Please write down the definition of identifiers.

must be the beginning of the letter, consisting of letters, numbers, underscores, and$

Determine if the following identifiers are correct:

1yyy_o (wrong)

Demo02 (right)

Abc$2 (right)

Class (yes)

Text!p (wrong)

Please calculate How many bits50MB is?

1024*1024*8*50

Please write down eight basic data types

Byte,short,int,long,double,float,boolean,char

Please write down the reference data type you know

Scanner,random,string

Write a program to find 1+3+5+7+......+99 and Values

int sum = 0;
for (int i =0;i<100;i++) {
if (i%2!=0) {
sum = sum+i;
}
}
SYSTEM.OUT.PRINTLN (sum);

output of all narcissus numbers, the so-called Narcissus number refers to a number 3 digits, its per digit cubic and equal to itself , such as 153 = 1*1*1 + 3*3*3 + 5*5*5

 for (int i=100;i<1000;i++) {        int a = i/100;         int b = (I/10)%10;         int c = i%10;         if (a*a*a+b*b*b+c*c*c==i) {            System.out.println (i);        }    }
Printing 9*9 tables with A For loop
 for (int i=1;i<9;i++) {            for (int j=1;j<=i;j++) {                System.out.print (J+ "*" +i+ "=" +j*i+ "\ T");            }            System.out.println ();        }
Defines a method for printing array elements, printing in a given format [11, 33, 44, 22, 55]
int [] ARRT ={11,33,44,22,55};              for (int i =0;i<arrt.length;i++) {                System.out.printl (arrt[i]);
Existing array arr[6,9,4,6,2,5,8], output array elements in reverse order
int [] ARRT ={6,9,4,6,2,5,8};          for (int i=arrt.length-1;i>0;i--) {            System.out.println (arrt[i]);        }

A two-dimensional array traversal gets to each value

int [] Intarr = {{12,3,8},{11,8,32,7},{13,44,55}};     int [] arr = {{12,3,8},{11,8,32,7},{13,44,55}};          for (int i= 0;i<arr.length;i++) {            for (int j=0;j<arr[i].length;j++ ) {                System.out.println (arr[i][j]);            }        }

Company Annual Sales sum

the data for a company by quarter and month are as follows: Unit ( million Yuan )

First quarter:22,66,44

second quarter:77,33,88

third quarter:25,45,65

fourth quarter:11,66,99

int [] arr ={{22,66,44},{77,33,88},{25,45,65},{11,66,99}};         int sum = 0;          for (int i=0;i<arr.length;i++) {            for (int j=0;j<arr[i].length;j++ {                = sum+arr[i][j];            }        }

define a student class Student, which contains three attribute names, age, and gender, creates three student objects to be stored in a ArrayList collection.

A: Iterates through the set traversal output.

B: Find the oldest student, let the name of the object become: Gourd Doll.

1Arraylist<stu> stu =NewArraylist<stu>();2Stu arr1 =NewStu ();3Stu arr2 =NewStu ();4Stu Arr3 =NewStu ();5Arr1.name= "Wang Rongshen";6Arr1.age = 23;7Arr1.sex = "Male";8 Stu.add (arr1);9Arr2.name = "Zhang Rui";TenArr2.age = 26; OneArr2.sex = "Male"; A Stu.add (ARR2); -Arr3.name = "Director"; -Arr3.age = 25; theArr3.sex = "Male"; - Stu.add (ARR3); -          for(intI=0;i<stu.size (); i++){ -System.out.println (Stu.get (i). name+ "\ T" +stu.get (i). age+Stu.get (i). Sex); +         } -         intA= Stu.get (0). Age; +          for(intI=0;i<stu.size (); i++){ A             if(Stu.get (i) .age>a) { atA=Stu.get (i). Age; -             } -         } -              for(intI=0;i<stu.size (); i++){ -             if(Stu.get (i). age==a) { -Stu.get (i). Name = "Gourd Doll"; in             } - System.out.println (Stu.get (i). name); to         }     +     } -}













Java Fundamentals Quiz

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.